Charles was the heir of three of Europe's leading dynasties: the Houses of Valois-Burgundy (through his paternal grandmother), Habsburg, and Trastámara (his maternal grandparents were the Catholic Monarchs of Spain). Upon the death of his maternal grandmother Queen Isabella I of Castile in 1504, Charles's mother Joanna inherited the kingdom of Castile. She was mentally insane and held little real power, with her father, King Ferdinand II of Aragon, and (briefly) her husband and co-ruler, Philip, Charles's father, serving as regents. Upon the death of Ferdinand V in 1516, Charles and Joanna ruled both Castile and Aragon together, as a unified Spain, although Joanna remained in confinement. Charles inherited the Netherlands and the Free County of Burgundy as heir of the House of Valois-Burgundy. As a Habsburg, he inherited Austria and other lands in central Europe. He was also elected to succeed his grandfather, Maximilian I, as Holy Roman Emperor, a title held by the Habsburgs since 1440. From the Spanish House of Trastámara, he inherited the Crown of Castile, which was developing a nascent empire in the Americas and Asia, and the Crown of Aragon, which included a Mediterranean empire extending to Southern Italy. Charles was the first king to rule Castile and Aragon simultaneously in his own right, and as a result he is often referred to as the first king of Spain. The personal union under Charles of the Holy Roman Empire with the Spanish Empire was the closest Europe would come to a universal monarchy since the death of Louis the Pious (778–840).