Philip V was the first Bourbon king, of French origin. Concern among other European powers that Spain and France united under a single Bourbon monarch would upset the balance of power led to the War of Spanish Succession between 1701 and 1714. It pitted powerful France and weak Spain against the Grand Alliance of England, the Netherlands and Austria. After many battles, especially in Spain, the Grand Alliance finally won.
He 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. Lynch says Philip V advanced the government only marginally over that of his predecessors and was more of a liability than the incapacitated Charles II. When a conflict came up between the interests of Spain and France, he usually favored France. However Philip did make some reforms in government, and strengthened the central authorities relative to the provinces. Merit became more important, although most senior positions still went to the landed aristocracy. Below the elite level inefficiency and corruption was as widespread as ever. The reforms started by Philip V culminated in much more important reforms of Charles III. The economy, on the whole, improved over the depressed 1650-1700 era, with greater productivity, and fewer famines and epidemics.
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 18th 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 18th 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.