Spain was among the first Western countries to get colonies in the 1500s, and it was among the first to lose its colonies in the 1800s. In 1810, Chile declared independence. Then in 1821, Mexico and Peru became independent too. At the same time, Spain began to rock back and forth between democracy and kings. King Ferdinand II began his reign as a very limited king, but he kept trying to get all his power back, killing lots of people in the process. Ferdinand let the Jesuits come back to Spain, too.
Near the end of his life, though, in 1829, Ferdinand married his niece Maria Christina, and she took over and worked for a more democratic, modern government.
After Ferdinand died, Maria Christina ruled as regent for their daughter Isabella. She limited the power of the Jesuits again, closed many monasteries and convents (and took their property for Spain’s government) and established a constitution. Isabella II took power for herself in the 1840s, like Victoria in England at the same time. Unlike her mother, Isabella was a conservative who brought back the Jesuits and refused to modernize Spain. Isabella won a war and took over more land in Morocco in 1860, demanding that Morocco pay a huge fine in exchange for peace.
People in Spain were angry about losing all the colonies, and they blamed the queens. In 1868, Spain finally had a revolution, and Isabella had to resign. For a few years Spain had its first Republic, and then Isabella’s son Alfonso became king after all. But Alfonso XII died of tuberculosis and dysentery when he was 27, in 1885, and his wife – another Maria Christina – ruled as regent for their son, Alphonso XIII.
Maria Christina continued the modernization of Spain. That meant that more and more politicians ran Spain while she was only a figurehead, like Victoria in England. Spain fought the Spanish-American war, and lost control of Cuba, Puerto Rico, and the Philippines. By 1900 AD, Spain was a democracy (though women still couldn’t vote), but the new government controlled only Spain itself.