After the defeat of the Guarani rebels, the Spanish and Portuguese forced the Guarani to abandon the seven reductions that had been ceded to Portugal in the Treaty of Madrid and to move to Spanish controlled lands. According to a census conducted in 1756 the population of the Guarani from the seven missions was 14,284, which was about 15,000 less than the population in 1750. The former Jesuit missions were occupied by the Portuguese-Brazilians until 1759 when Spain unilaterally ended the Treaty of Madrid and reclaimed the lands of the seven missions. The border of the La Plata colonial region was finalized by the Treaty of San Ildefonso in 1777.

Answer this question based on the article: Which happened later, the ending of the Treaty of Madrid or the inception of the Treaty of San Ildefonso?
the Treaty of San Ildefonso