The town "Wiener Neustadt" was established in 1194 by the Babenberg Duke Leopold V. Until 1192, the area belonged to the Duchy of Styria. After the dynasty of the Otakars became extinct with the death of his son Ottokar IV, the Duchy of Styria passed to the Austrian House of Babenberg.
The construction of a new, fortified town was necessary because the previous border fortress against Hungary, Pitten, had already fallen into disrepair and no longer offered sufficient protection against the constant incursions of the Hungarians. The new town was named "Wiener Neustadt" - meaning more or less New Vienna ("Viennese Newtown").
The construction was financed with the ransom paid for the English king Richard the Lionheart, whom Leopold V. had previously captured and held as a hostage at Dürnstein Castle.
The southeast corner of the town was chosen as the location of the castle because it was closest to the natural border formed by the Leitha-river and because the terrain was swampy and therefore easy to defend. Because of the swamp, the castle had to be built on piles.