Spanish colonies in the Western Hemisphere followed a different path to independence than those of other European countries. Like in the land that became the United States, Spanish colonizers were brutal, violent, and led what was effectively a genocide of the native indigenous cultures in the Americas. However, surviving indigenous peoples intermarried with Spanish colonists, creating a unique Latin American identity in Spanish colonies that became increasingly separate and distinct from Spain.
The first steps towards independence were the result of the Napoleonic invasion of Spain by France in the early 19th century. During the Napoleonic war, Spain formed the Supreme Central and Governing Junta, which was an effort to coordinate Spanish efforts against the invading French after the Spanish monarchy abdicated the throne. This prompted some Latin American countries to form their own juntas (or councils) who refused to recognize the authority of an ad hoc government who they considered moments away from French takeover anyway. Eager to limit French involvement with the oncoming exchange of power, Latin American colonies began to express their own political power for the first time. Once they had a taste, it would be difficult for them to relinquish.
The Napoleonic invasion brought years of political turbulence to Spain and, eventually, the restoration of the absolutist monarchy of Ferdinand VII. Having grown accustomed to expressing their own political power, the Latin American colonies began to push back against the involvement of Spain. Seeing successful independence movements throughout the Western Hemisphere in the United States, Haiti, and Brazil, the Spanish colonies could see concrete examples of a future without the unstable colonial rule of a government thousands of miles away. In particular, it was a government that no longer represented the colonies, as their Latin American culture became increasingly distinct from Spain.
As Spain dealt with its own political instability at home, their American colonies seized the opportunity. Within several decades, almost all of the previously Spanish colonies had achieved independence. The only colonies that did not separate from Spain were Puerto Rico and Cuba, both of which would remain under Spanish rule until the Spanish American war in 1898.