were separated from this enormous empire at the Diet of Worms in 1521, when Charles I left them to the regency of his younger brother, Ferdinand I (1521–1564), although he then continued to add to the Habsburg territories. Since Charles left his Spanish Empire to his son Philip II of Spain, the Spanish territories became permanently alienated from the northern Habsburg domains, although remained allies for several centuries. By the time Ferdinand also inherited the title of Holy Roman Emperor from his brother in 1558 the Habsburgs had effectively turned an elective title into a de facto hereditary one. Ferdinand continued the tradition of dynastic marriages by marrying Anne of Bohemia and Hungary in 1521, effectively adding those two kingdoms to the Habsburg domains, together with the adjacent territories of Moravia, Silesia and Lusatia. This took effect when Anne's brother Louis II, King of Hungary and Bohemia (and hence the Jagiellon dynasty) died without heir at the Battle of Mohács in 1526 against Suleiman the Magnificent and the Ottomans. However, by 1538 the Kingdom of Hungary was divided into three parts: The Kingdom of Hungary (Royal Hungary) (today Burgenland, parts of Croatia, mostly Slovakia and parts of present-day Hungary) recognised the Habsburgs as Kings. Ottoman Hungary (the center of the country). Eastern Hungarian Kingdom, later the Principality of Transylvania under counter kings to the Habsburgs, but also under Ottoman protection. Ferdinand's election to emperor in 1558 once again reunited the Austrian lands. He had had to cope with revolts in his own lands, religious turmoil, Ottoman incursions and even contest for the Hungarian throne from John Sigismund Zápolya. His lands were by no means the most wealthy of the Habsburg lands, but he succeeded in restoring internal order and keeping the Turks at bay, while enlarging his frontiers and creating a central administration. When Ferdinand died in 1564, the lands were once more divided up between his three sons, a provision he had made in 1554. Austria in the Reformation and Counter-Reformation (1517–1564) Martin Luther and the Protestant Reformation (1517–1545) When Martin Luther posted his ninety-five theses to the door of the Castle Church in Wittenberg in 1517, he challenged the very basis of the Holy Roman Empire, Catholic Christianity, and hence Habsburg hegemony. After the Emperor Charles V interrogated and condemned Luther at the 1521 Diet of Worms, Lutheranism and the Protestant Reformation spread rapidly in the Habsburg territories.