In 1640, major rebellions broke out in Portugal and
. Portugal regained its independence, which was recognized in 1668, while the other region was eventually brought back under Spanish control.
In 1648, the Peace of
ended Thirty Years' War and the Eighty Years' War with Spain recognizing
independence.
In 1659, the Treaty of the
ended fighting with
and marked the decline of Spain as a leading European power.
In 1697, Spain signed the Treaty of Rijswijk to cede the western half of
to France, which named its new colony
.
In 1700, the death of childless
started the War of Succession from 1700 to 1714 between Bourbon and
.
Around 1713 to 1714, the Treaty of
, Bourbon
(reigned 1700-1746) was recognized as King. Spain lost its Italian territories, Menorca, Gibraltar, and the
. Between 1707 and 1716, the Bourbon monarchy centralized the state, abolishing autonomous assemblies in territories like Catalonia and
.
In 1739, Venezuela, Colombia and
became part of the re-established Spanish viceroyalty of
, with
as the capital.
During the reign of
(1746-1759), Spain experienced a rare period of neutrality and recovery. Following the constant warfare of his father, Philip V, he pursued a policy of "Peace with all, war with none."
In 1759,
took over the throne. His reign was the pinnacle of the Enlightened Despotism in Spain. He sought to modernize Spain into a centralized, efficient, and scientifically advanced European power. He reigned for 29 years until 1788.
In 1776, Spanish America was administered as four viceroyalties: New Spain, Peru, New Granada, and
.
was chosen as the capital of the new Spanish viceroyalty of La Plata.