Not even Frodo trying desperately to cut his way out of Shelob the Spider’s thick cobwebs is like my trying to explain the War of the Spanish Succession. Let us go at it in stages, keep a clear mind and watch out for the snags:
Charles II (Carlos Segundo) died childless in Spain in 1700. A sister had married Louis XIV (the Sun King of France). Another sister had married the Holy Roman Emperor (q.v.) Leopold I. Consequently, both the French Bourbons and the Austrian Habsburgs (q.v.) claimed the right to rule Spain itself and the Spanish Empire. The latter included the southern part of the Netherlands, Milan, Naples, and almost all of Central and South America. There was a lot at stake.
Before Charles II (Carlos Segundo, not to be confused with Charles II of Britain) had died, William III (originally of Orange) had inspired and attended negotiations to avoid the crisis that was bound to occur. William’s motives were mainly religious; it was the usual headache, Protestantism versus Catholicism.
In 1698 a Partition Treaty was signed between Louis the Sun King and William, agreeing that Spain and her possessions should be shared out between France, Austria and Joseph Ferdinand (José Fernando), aged seven, Elector of Bavaria and grandson of Leopold through his mother, Maria Antonia. Here lay one of the problems; Spain herself seemed not to have much to do with these negotiations, and it rankled.
Charles II however agreed to leave all Spain’s empire to Joseph Ferdinand. He then died, and before you could say ‘War!’ Louis XIV and William III signed a second partition in 1699. A will signed by Charles II was then found leaving the entire empire to the grandson of Louis XIV, the future Philip V! Louis decided to accept the terms of this will rather than his previously made agreements. Europe was afraid of too much French domination and said so.
The Sun King then enraged everyone by intervening in Spanish affairs; he seized some Dutch border fortresses, at the same time recognising the son of the exiled British king James II (Roman Catholic) as future King of England. As if this were not enough, he refused to allow it to be impossible for Philip also to inherit the French throne as the royal Duke of Anjou (duc d’Anjou). War was inevitable.
In 1701 William III formed an alliance between the English and Dutch together with the Austrian emperor and most of the German princes and arch-dukes to put the rival Austrian candidate Archuke Charles on the Spanish throne. Savoy and Portugal joined in the scrum. William died inconveniently for the Protestant cause and his place was taken by his successor Queen Anne.
Most of the fighting (many soldiers on both sides were mercenaries) took place in the Netherlands, Italy, Germany and of course Spain. Bavaria fought for France. The people of Castilia stood by Philip V while the Catalans declared for Archduke Charles. The Duke of Marlborough, John Churchill, won a tremendous victory at Blenheim, aided by Eugène of Savoy. France was invaded in 1709 and the gallant Allies also won some battles on the high seas, seizing Gibraltar in 1704. This has been an arguing point between England and Spain ever since, and still is. The War continued until everyone grew rather tired of it, and when the Duke of Marlborough fell out of favour in Britain in 1711, the new Tory government began the negotiations that lead to peace and The Treaty of Utrecht in 1713.
Philip V became Felipe Quinto, King of Spain, but the Anjou connection has always claimed both kingdoms, France and Spain, ever since. There is still a claimant, the comparatively young and very agreeable Louis Alfonso, duke of officially-accepted heir to the non-existent French throne.