Chile and Mexico both share a common history in that they were both hosts to advanced indigenous societies and were both colonized by Spain. Diplomatic relations were established in the 1820s soon after both nations obtained independence from Spain. In 1825 Chile opened a consulate in Mexico City and in Mazatlán in 1875. On 7 March 1831, both nations signed a Treaty of Friendship, Trade and Navigation. In 1844, Mexico opened a consulate in Valparaíso. In 1864, during the Second French intervention in Mexico, Chile recognized and maintained diplomatic relations with the government of President Benito Juárez. In the early 1900s, both nations established resident embassies in each other's capitals respectively.