From 1521, Spain had conquered the territory known today as Mexico and subjugated the indigenous civilizations living there, founding a colony which would be elevated to the category of viceroyalty in 1535 called New Spain. Spain ruled over Mexico for three centuries. On September 16, 1810, the Mexican War of Independence began with the so-called Cry of Dolores. The war ended in 1821, with the signing of the Treaty of Cordoba on August 24 and the Declaration of Independence of the Mexican Empire on September 28 of that year. This act was the result of the negotiations of the different factions participating in the war, including Juan O'Donojú, the last viceroy of New Spain on behalf of the monarchy. However, Spain would not recognize the treaties and the declaration on the grounds that O'Donojú was unable to make such arrangements. Even though most of the royalist armies within the Mexican territory had ceased hostilities and recognized the Treaties of Cordoba, the military incursions of Spain to try to reincorporate Mexico into its empire, did not cease for more than a decade. In 1825, the Spanish army seized the fortress of San Juan de Ulúa but was forced to retreat by Mexican forces. Later, another attempt by the Iberian country to reconquer Mexico culminated in the Battle of Tampico in 1829. Meanwhile, Mexico had tried unsuccessfully to take the island of Cuba, a bastion of the royalist government in the Gulf of Mexico, in order to diminish the influence of Spain on these seas, to prevent further incursions and open a way out to the Atlantic Ocean.
The treaty
In 1833, King Ferdinand VII died. He had ascended to the throne shortly before the wars for the independence of the American colonies began, leaving Spain in a terrible economic situation. He was succeeded by his daughter Isabella II, who was then a minor, so his mother Maria Cristina assumed the regency of the country, coinciding with the start of the First Carlist War due to the conflict of succession with Carlos María Isidro de Borbón, brother of Ferdinand VII. For this reason, María Cristina decided to adopt a more liberal attitude towards her government in order to attract popular support. This would be reflected, also, in a more open position regarding relations with the American countries to motivate trade and reactivate the damaged Spanish economy. In 1835, Mexico appointed Miguel Santa María, who was already minister in the United Kingdom, as minister plenipotentiary to sign the peace treaty. For its part, the Spanish Regency appointed José María Calatrava. The treaty was signed in Madrid on December 28, 1836. It was published in Mexico on March 4, 1838.