The First Treaty of San Ildefonso was signed on 1 October 1777 between the Spanish Empire and the Portuguese Empire, shortly after the crowning of Mary I of Portugal and dismissal of Sebastião de Melo, Marquis of Pombal as de facto ruler of Portugal.
The agreement mainly settled territorial disputes in the Río de la Plata region. Based on the terms of the agreement, Spain ceded territories in Brazil to Portugal (i.e. Amazon Basin) in return for maintaining control over the Banda Oriental (i.e. Uruguay). The treaty partly reaffirmed the Treaty of Madrid (1750) since Spain managed to keep both the Misiones Orientales and Colonia del Sacramento.