Spain, as the first major European power in the New World, possessed a vast empire at its height in the 1500's. However, by the early 1800's, the Spanish colonies in Central and South America began to revolt and break away from Spain, the first in the 1820's. They were inspired to do so by the precedence set by the United States revolting and successfully breaking away from Great Britain.
It wasn't just the US example; in the intervening centuries Spanish power in the New World had been declining. As Spain's political and economic influence waned, the colonies saw their chance. This culminated in the Spanish-American War in 1898, when Spain as a political power was finally driven out of the New World.