Aragón as a kingdom arose with the death of the Navarrese monarch, Sancho Garcés III The Elder. The territories under his command were divided between his four children: Ramiro I, inherited what was then the county of Aragon; García, his legitimate firstborn, reigned in his native Navarra; Fernando was given the county of Castile, and finally, Gonzalo was given Sobrarbe and the Ribagorza, two small Pyrenean counties.
In spite of not being anointed as such, all the documents of the time treat Ramiro I as a king, since he held the potestas regia in the territories under his control.
The four brothers focused on securing the territories they had inherited, which generated disputes among them. Ramiro strengthened the northern border by marrying Gisberga Ermesinda, daughter of Bernardo Roger, Count of Bigorre, in the year 1036. Later, in 1044, his brother Gonzalo died, and Ramiro annexed the territories that he had inherited, the Sobrarbe and the Ribagorza.
To the west, and around the main territories of our route, Ramiro and García Sánchez, at that time monarch of Navarre, disputed the border between their kingdoms. One of these confrontations ended with the hurried escape of King Ramiro.
In the year 1037 Ramiro used a past conflict in which he had provided soldiers to his brother, as an excuse to reclaim territories. Ramiro set out to take Tafalla, hastily and without his best men, but he was attacked at night by the Navarre forces and had to abandon his project and return to his domain. The king passed through towns like Sos, Navardún and Los Pintanos in his flight.