The Taifa of AlbarracÃÂn () was a medieval Berber taifa kingdom. The polity existed from 1012 to 1104, and was centered at the city of AlbarracÃÂn. It was led by the Berber dynasty of the Banu Razin tribe, which arrived in the peninsula after the conquest of Spain by Tariq ibn Ziyad.
In 1167, under the pressure from the ongoing wars between the Almoravids and the new invasions by the Almohad Caliphate. The Moorish Emir Muhammad ibn Mardanis ceded the Taifa of AlbarracÃÂn to a vassal of Sancho VI of Navarre, a noble from Estella-Lizarra named Pedro Ruiz de Azagra. The title was granted to d'Azagra due to his support of the Navarrese Crown against Alfonso VIII of Castile and Alfonso I "the Battler" of Aragón.
In 1172, Pero RuÃÂz d'Azagra managed to consolidate his power over the SeñorÃÂo making that territory independent of the other Christian kingdoms in the region. In 1190, with the signing of the Borja Accords, between Alfonso II of Aragon and Sancho VI of Navarre, the two monarchs agreed to a defensive pact against Alfonso VIII of Castile which gave official legitimacy to the SinyorÃÂa d'AlbarrazÃÂn with respect to the two kingdoms.