During the 16th century, Spain was the most powerful country in the world, but the 17th century saw its decline for several reasons: Spain spent vast amounts of money and resources participating in the Thirty Years' War and other conflicts, losing territories like Portugal in the process. The kings spent lavishly on wars but neglected infrastructure and the populace, impoverishing the country further, while pirates also attacked Spanish ships, preventing gold and silver from America from reaching Spain. The kings were disinterested in ruling as well, leaving government in the hands of validos, or favorite ministers.