Juan Ruiz de Apodaca
Juan Ruiz de Apodaca governed New Spain from 1816 until July 1821, when royalist officers deposed him as Agustín de Iturbide’s independence movement gained ground. His successor, Juan O’Donojú, arrived with the title of jefe político superior (superior political chief) rather than viceroy, which is why Apodaca counts as the last to hold the viceregal title.
O’Donojú went on to sign the Treaty of Córdoba in August 1821, recognizing Mexico’s independence.