In 1807 French forces occupied Spain and imprisoned the king. This caused unstability throughout Spainís colonial possessions, including Mexico. Spain became a nation in rapid decline, suffering from both internal and colonial revolt. In 1820, a revolt by liberals in Spain greatly weakened the authority of the monarch, and Mexican Creoles seized the opportunity to liberate themselves from Spanish authority.
By then, the Spanish forces had lost command in Mexico. The likelihood for a revolt, made the last Spanish officials withdraw from Mexico in 1821. The struggle for power in Europe made Spain give up their intentions in America and ended more then three centuries of Spanish rule in South-America.