The Spanish Empire's international dominance and great wealth of the early 16th century, due in great part to the silver and gold imported from the New World, began to hit turbulance in the later part of the century. By the 17th century, Spain was submerged in the throes of a major crisis. They began to lose their territories and international credibility, there were revolts in Cataluña and Portugal (which Spain quickly lost), political tension wracked the monarchy and poverty was widespread.
In the 18th century, things went from bad to worse. After the death of an heirless king, Spain was thrust into the War of Spanish Succession between the French-backed Bourbon dynasty's Felipe V and the Britain-backed Archduke Carlos of Austria. Felipe eventually won the crown, but the war-ending Treaty of Utrecht (1713) stripped Spain of its power in Belgium, Luxembourg, Italy, Gibraltar and Sardinia.
The 19th century was plagued by wars, starting off with the early part of the century's Napoleonic Wars. Spain's ties with France through the Bourbon dynasty made Spain's involvement inevitable; the Spanish fleet was defeated in 1805 at the Battle of Trafalgar. However, local resistance against French forces throughout Spain eventually drove the French back out. Meanwhile, as the American colonies began pushing for and attaining independence, Spain's international importance went out the window.
The mid-19th century held yet another succession war - called the First Carlist War- in store for Spain. The war, fought between supporters of Fernando VII's young daughter and his brother, divided the country. His daughter, Isabel II, eventually won out and wore the crown for a reign dogged by continued scandal, political crisis and constitutional compromise.