A proximate cause of the Spanish empire was the Netherlands War of Independence (which lasted 80 years), and other revolts against Spain. http://en.wikipedia.org/wiki/Eighty_Years%27_War
The Spanish Empire had been "cobbled" together in the late 15th and early 16th centuries by the marriage of the Ferdinand of Aragon and Isabella of Castile, whose daughter Juana married Philip, the son of Maximilian of Austria and Marie of Burgundy (who lost that province to France, but kept the Netherlands including modern Belgium). Charles V, the son of Juana and Philip, inherited Spain, the Netherlands and Austria. But when he subdivided it, the Netherlands went together with Spain to Charles' son Philip, instead of to Charles brother Ferdinand, who got Austria and Bohemia and the Holy Roman Empire.
The Netherlands rebelled against Philip and later Spanish rulers, so it became a major liability, instead of a major asset, especially since the war dragged on for 80 years, (with some breaks), during which Spain went bankrupt several times. Philip had annexed Portugal in 1580, but that rebelled in 1640 and broke away. EvemEven Catalonia (part of the old Aragon) rebelled in the middle of the 17th century, although Spain managed to hang ontoon to it. But fighting all these wars, plus a short but costly "Armada" war with England set Spain on a downward spiral through the 17th and 18th centuries.