Treaty of Badajoz (1267)
The Treaty of Badajoz was signed in Badajoz on 16 February 1267 between King Alfonso X of Castile and King Afonso III of Portugal. Both signatories agreed to establish lines of mutual assistance and friendship. Based on the terms of the accord, Alfonso X surrendered all rights to the Kingdom of the Algarve, which included the service of fifty knights. Moreover, he commanded his lieutenants to surrender the castles they controlled in Algarve to the Kingdom of Portugal. Despite all this, Alfonso X still continued to use the title "king of the Algarve" even though it  was probably used in reference to the territory of Niebla. Both signatories agreed to use the Guadiana River from Elvas and Badajoz to Ayamonte on the Atlantic Ocean as the boundary line separating Castile and Portugal. This, in turn, forced Portugal to surrender Aracena, Moura, Serpa, and Aroche located east of the boundary line. North of the boundary line, Portugal was able to maintain Arronches, Alegrete, and Elvas, but was forced to capitulate Valencia de Alcántara and Marvão. The Treaty of Badajoz was succeeded by several other treaties as rivalry between Portugal and Castile persisted. Some of these treaties included  those signed by Denis I and King Ferdinand of Castile in 1297 as well as the treaty signed in 1339. Later, in 1801, Spain waged war against Portugal and invaded Badajoz. This event was concluded by a peace agreement, which was also called Treaty of Badajoz. This required Portugal to relinquish a number of territories, including the town of Olivença while the Guadiana River once again delineated the border between the two countries.