Philip V, the first Bourbon king, of French origin, signed the Decreto de Nueva Planta in 1715, a new law that revoked most of the historical rights and privileges of the different kingdoms that formed the Spanish Crown, specially Crown of Aragon, unifying them under the laws of Castile, where the Cortes had been more receptive to the royal wish. Spain became culturally and politically a follower of absolutist France. The rule of the Spanish Bourbons continued under Ferdinand VI and Charles III. Great influence was exerted over Elisabeth of Parma on Spain's foreign policy. Her principal aim was to have Spain's lost territories in Italy restored. She eventually received Franco-British support for this after the Congress of Soissons.
Under the rule of Charles III and his ministers, Leopoldo de Gregorio, Marquis of Esquilache and José Moñino, Count of Floridablanca, Spain embarked on a program of enlightened despotism that brought Spain a new prosperity in the middle of the eighteenth century. Fearing that Britain's victory over France in the Seven Years War threatened the European balance of power, Spain allied themselves to France but suffered a series of military defeats and ended up having to cede Florida to the British at the Treaty of Paris. Despite being on the losing alongside France against the British in the Seven Years' War, Spain recouped most of her territorial losses in the American Revolutionary War, and gained an improved international standing.
However, the reforming spirit of Charles III was extinguished in the reign of his son, Charles IV, seen by some as mentally handicapped. Dominated by his wife's lover, Manuel de Godoy, Charles IV embarked on policies that overturned much of Charles III's reforms. After briefly opposing Revolutionary France early in the French Revolutionary Wars, Spain was cajoled into an uneasy alliance with its northern neighbor, only to be blockaded by the British. Charles IV's vacillation, culminating in his failure to honour the alliance by neglecting to enforce the Continental System led to Napoleon I, Emperor of the French, invading Spain in 1808, thereby triggering Spain's War of Independence.
During most of the eighteenth century Spain had made substantial progress since its steady decline in the latter part of the 17th century, under an increasingly inept Habsburg dynasty. But despite the progress, it continued to lag in the political and mercantile developments then transforming other parts of Europe, most notably in the United Kingdom, France and the Low Countries. The chaos unleashed by the Napoleonic intervention would cause this gap to widen greatly.