Aragon was originally a Carolingianfeudalcounty around the city ofJaca, which in the first half of the 9th century became a vassal state of the kingdom of Pamplona, its own dynasty of counts ending without male heir in 922. The name Aragón is the same as that of the river Aragón, which flows by Jaca. It might derive from the BasqueAragona/Haragona meaning "good upper valley". Alternatively, the name may be derived from the earlier Roman province of Hispania Tarraconensis. On the death of Sancho III of Navarre in 1035, the Kingdom of Navarre was divided into three parts: Pamplona and its hinterland along with western and coastal Basque districts, Castile, and Sobrarbe, Ribagorza and Aragon. Sancho's son Gonzalo inherited Sobrarbe and Ribargorza, whereas his illegitimate son Ramiro received Aragon, but Gonzalo was killed soon after and all the land he owned went to his brother Ramiro, thus becoming the first de facto king of Aragon, although he never used that title. By defeating his brother, García Sánchez III of Navarre, Ramiro achieved independence for Aragon. His son Sancho Ramírez, who also inherited the kingdom of Navarre, was the first to call himself "King of the Aragonese and Pamplonese". As the Aragonese domains expanded to the south, conquering land from Al Andalus, the capital city moved from Jaca to Huesca, and later to Zaragoza. After Alfonso the Battler died childless in 1135, different rulers were chosen for Navarre and Aragon, and the two kingdoms ceased to have the same ruler. By 1285 the southernmost areas of what is nowadays Aragon had been taken from the Moors.
The Crown of Aragon became a part of the Spanish monarchy after the dynastic union with Castile, which supposed the de facto unification of both kingdoms under a common monarch. The house of Barcelona held the Crown until 1410, when it went extinct. Subsequently, in 1412 the Aragonese secured the election of a Castilian prince, Ferdinand of Antequera, to the vacant Aragonese throne, over strong Catalan opposition. One of Ferdinand's successors, John II of Aragon, countered residual Catalan resistance by arranging for his heir, Ferdinand, to marry Isabella, the heir apparent of Henry IV of Castile. In 1479, upon John II's death, the crowns of Aragon and Castile were united to form the nucleus of modern Spain. However, Aragonese territories retained their autonomous parliamentary and administrative institutions, such as the Corts, until the Nueva Planta decrees, which were promulgated between 1707 and 1715 by Philip V of Spain in the aftermath of the War of the Spanish Succession. The decrees de jure ended the kingdoms of Aragon, Valencia and Mallorca, and the Principality of Catalonia, and merged them with Castile to officially form the Spanish kingdom. A new Nueva Planta decree in 1711 restored some rights in Aragon, such as the Aragonese Civil Rights, but preserved the end of the political independence of the kingdom. The previous Kingdom of Aragon remained as an administrative unit until 1833, when it was divided into the three existing provinces. In the aftermath of Francisco Franco's death, Aragon became one of the autonomous communities of Spain in 1982.