An unexpected turn in the history of the town was brought by the 16th century . In a tragic battle with Turks at Moháč in 1526 , the Hungarian King Louis II perished. Ferdinand of Hapsburg was elected new king at a session in the Franciscan church in Bratislava, despite the rival candidate Ján Zápoľský and despite the resistance of part of the Hungarian nobility. With the Turks fast advancing into the country the Hungarian nobility protected themselves by fleeing to the present territory of Slovakia, where state offices were also moving. In 1530, the Turks finally threatened Bratislava, partially damaging it with shellfire.
The disaster that afflicted Hungary after the battle at Moháč was, paradoxically, positive for Bratislava. After the capital city Buda was occupied, Hungarian nobility along with secular and church dignitaries were looking for a refuge north of the Danube and as close as possible to where the King, Ferdinand, was residing. The convenient position and relative safety of Bratislava decided that it was to become the capital city of Hungary. It was confirmed as such by the Hungarian assembly at its session in 1536 . The town of merchants, craftsmen and wine-growers became the residential city of the country, seat of nobility and the church. Bratislava became an assembly city of the Kingdom and a coronation city of Hungarian kings, residence of the king, the archbishop, as well as that of the most significant institutions of the country. During 1536 – 1830, 11 kings and queens were crowned in the Dome of St. Martin.