In the late 17th century, Spain had a huge empire, fuelled by colossal amounts of gold. By the time it got to the 19th century, it didn't even have the strength to keep Napoleon out of its homeland. But I don't know a lot about Spanish history, so I don't know what happened during that time.
Perhaps this post might answer your question?