After Mexico's independence in 1821, a large body of Spanish troops continued to occupy San Juan de Ulúa as late as 1825. It was the last site in the former colony of New Spain to be held by the Spanish and was surrendered to Mexican General Miguel Barragán in November 1825. The justification for the order of expulsion issued by President Vicente Guerrero was their failed attempt at re-conquering Mexico. Since then, San Juan de Ulúa served as a military and political symbol of Mexican resistance to foreign invasions and occupations, thanks to several of which took place during the nineteenth century. In 1836 the French bombarded the fortress in the Battle of Veracruz during the Pastry War, a conflict resulting from a French citizen in Mexico seeking reparations for his allegedly damaged pastry shop; during the Mexican–American War, the United States laid siege to the fortress during the war, a conflict which resulted from disputes over the nascent Republic of Texas, and in 1863 the French briefly occupied the city when installing Maximilian I as emperor of Mexico. For much of the nineteenth century, the fort served as a prison, especially for political prisoners judged to be opposition to the government. Many prominent Mexican politicians spent time here while they were not in power.