Treaty of Madrid (13 January 1750)

The Spanish–Portuguese treaty of 1750 or Treaty of Madrid was a document signed in the Spanish capital by Ferdinand VI of Spain and John V of Portugal on 13 January 1750, to end armed conflict over a border dispute between the Spanish and Portuguese empires in South America in the vicinity of the Uruguay River, an area known as the Banda Oriental (now comprising parts of Uruguay, Argentina and the state of Rio Grande do Sul, Brazil). The treaty established borders between the Spanish and Portuguese empires, ceding much of what is today's country of Brazil to the Portuguese.
Background.
Earlier treaties such as the Treaty of Tordesillas and the Treaty of Zaragoza authored by both countries, and as mediated by Pope Alexander VI, stipulated that the Portuguese empire in South America could extend no farther west than 370 leagues west of Cape Verde Islands (called the Tordesillas meridian, approx. the 46th meridian). Had these treaties remained unchanged, the Spanish would have held both what is today the city of São Paulo and all land to the west and south. Thus, Brazil would be only a fraction of its present-day size.
Gold was discovered in Mato Grosso in 1695. The Portuguese made gains in the lower Amazon.
Starting in the 17th century, Portuguese explorers, traders, and missionaries from the state of Maranhao in the north, and gold-seekers and slave-hunters, the famous "bandeirantes" of São Paulo, in the south, had penetrated far to the west and far to the south of the old imaginary treaty-line.
New captaincies (administrative divisions) created by the Portuguese beyond Brazil's previously-established boundaries: Minas Gerais, Goias, Mato Grosso, Santa Catarina.
International context.
The Philippines and Moluccas were under Spanish sovereignty.
Structure of the Treaty.
The original was in both Portuguese and Spanish. The treaty consists of a lengthy preamble, and 26 articles.
Terms of the Treaty.
The Treaty of Madrid was based on the principles of "Uti possidetis, ita possideatis" from Roman law (who owns by fact owns by right) and “natural boundaries”, stating respectively in the preamble: “each party must stay with what it now holds” and “the boundaries of the two Domains... are the sources and courses of the most notable rivers and mountains”, and thereby authorizing the Portuguese to retain the lands they had occupied at the expense of the Empire of Spain. The treaty also stipulated that Spain would receive the Sacramento Colony and Portugal the Misiones Orientales. These were seven independent Jesuit missions of the upper Uruguay River. The Treaty of Tordesillas was specifically abrogated.
The treaty sensibly sought to follow geographic features in fixing the boundary: it moved westward from a point on the Atlantic coast south of Rio Grande do Sul, then northward irregularly following parts of the Uruguay, Iguaçu, Paraná, Paraguay, Guapore, Madeira, and Javari Rivers, and north of the Amazon, ran from the middle Negro to the watershed between the Amazon and Orinoco basins and along the Guiana watershed to the Atlantic. 
Soon after signing it, two commissions for demarcation were created. The Northern, chaired by the State Governor of Grão-Pará and Maranhão, in the South headed on the Portuguese side by the Governor of Rio de Janeiro.
Aftermath.
The Treaty of Madrid was significant because it substantially defined the modern boundaries of Brazil. However, the resistance of the Jesuits to surrendering their missions and the refusal of the Guarani to be forcibly relocated led to the nullification of the treaty by the subsequent Treaty of El Pardo, signed by both countries in 1761. The opposition by the Guarani led to the Guarani War of 1756. The terms of the Treaty of Madrid, with a few exceptions, were re-established in the First Treaty of San Ildefonso in 1777, and that treaty was again negated in 1801.