Treaty of El Pardo (1778)

The Treaty of El Pardo signed on 11 March 1778 finalised colonial borders between Spain and Portugal in the Río de la Plata region of South America. Portugal acquired Spanish territories in South America (deep into the continent), later on given to Brazil, Spain acquired Portuguese territories in Africa, today known as the independent state of Equatorial Guinea.
Background.
For nearly 300 years, differing interpretations of the Treaty of Tordesillas led to border disputes between Spain and Portugal over the Río de la Plata region. Portuguese encroachments in the Río de la Plata allowed their merchants to evade commercial restrictions imposed by Spain on the importation of goods into Spanish South America, with Buenos Aires becoming a major centre for smuggled goods. 
The two countries attempted to finalise their borders by the 1750 Treaty of Madrid but in 1761, it was annulled by the new Spanish monarch Charles III. In 1762, Spain entered the Seven Years' War on the side of France; while an invasion of Portugal ended in disaster, the Spanish captured Colonia del Sacramento, now in Uruguay and much of the modern day Brazilian state of Rio Grande do Sul. Colonia del Sacramento was returned to Portugal by the 1763 Treaty of Paris.
Over the next decade, Portugal reoccupied Rio Grande do Sul in an undeclared war before formal hostilities commenced in the 1776-1777 Spanish–Portuguese War. In February 1777, a Spanish expeditionary force of 116 ships and 19,000 troops captured the island of Santa Catarina in February before moving against Colonia del Sacramento which surrendered in July. Fighting ended in February 1777 when Joseph I of Portugal died and his daughter, Spanish-born Maria I, sued for peace.
The First Treaty of San Ildefonso signed on 1 October 1777 established a Boundary Commission to demarcate borders between the two Empires in the Río de la Plata region. These were later confirmed by the Treaty of El Pardo.
Provisions.
The Treaty confirmed the findings of the Boundary Commission, Portugal gaining possession of modern-day Brazil while ceding Colonia del Sacramento to Spain.
It also included a number of commercial clauses, the most significant being the regulation of the tobacco and slave trades. Spain regained a base for the African slave trade it relinquished in the 1479 Treaty of Alcáçovas, with the acquisition of the Portuguese islands of Annobón and Bioko or Fernão Pó, plus the mainland between the Niger River and the Ogoue River. These possessions were administered by the Spanish Viceroyalty of the Rio de la Plata whose capital was Buenos Aires.
Aftermath.
Spanish hopes settling the border would help economic growth were hampered by the 1779-1783 war with Britain that restricted trade with mainland Spain and led to high tariffs and taxes to pay for it. Portugal regained the Misiones Orientales in the Treaty of Badajoz (1801) while in the Napoleonic Wars the loss of much of the Spanish navy at the Battle of Trafalgar in 1805 severed links between the central government and their overseas possessions, the Spanish criollos were still able to successfully defend The Rio de la Plata from British invasion in both 1806 and 1807 British invasions of the River Plate. Between 1809 and 1829, the Spanish American wars resulted in the independence of Spanish colonies in the Americas, the Viceroyalty of Río de la Plata being dissolved during the 1810-1818 Argentine War of Independence.
The territories in Africa gained by the Treaty of El Pardo became the colony of Spanish Guinea. Annobón and Bioko had been relatively neglected by the Portuguese, who focused instead on São Tomé; with the gradual abolition of the transatlantic slave trade in the first half of the 19th century, these lost much of their value to Spain. In 1968, Spanish Guinea became the independent country of Equatorial Guinea.