 In 1440 the territory of present-day Burgenland was controlled by the Habsburgs of Austria, and in 1463 the northern part of it (with the town of Kőszeg) became a mortgage-territory according to the peace treaty of Wiener Neustadt.In 1477 King Matthias Corvinus of Hungary had retaken the area, but in 1491 it was mortgaged again by King Vladislaus II of Bohemia and Hungary to Emperor Maximilian I.In 1647 Emperor Ferdinand II returned it to the Kingdom of Hungary (which itself was a Habsburg possession in this time).