On William's death in 1702, his sister-in-law Anne (Protestant younger daughter of James II and his first wife) succeeded him.
Within months, another war in Europe had started (the War of the Spanish Succession), which was to overshadow most of Anne's reign. A series of military victories by John Churchill, Duke of Marlborough, strengthened England's negotiating position at the end of the war.
Under the 1713 Treaty of Utrecht, France recognised Anne's title and exiled James II's Roman Catholic son, James Stuart, from France. The treaty also confirmed England's possession of Gibraltar.
Party politics became more significant throughout Anne's reign, with Whigs (who supported limited monarchy, and whose support tended to come from religious dissenters) and Tories (who favoured strong monarchy and the religious status quo embodied in the Church of England) competing for power.
During the final years of the seventeenth century, the Parliaments of England and Scotland had conflicting foreign and economic policies. Difficulties reached a climax when England settled the succession on the Protestant Electress Sophia of Hanover (Charles I's niece and cousin to James II), as Anne, the last surviving Protestant descendant of Charles II, had failed to produce an heir.
The Scots declared that they were free to choose someone different, with the implication that this could be the exiled Roman Catholic Prince James Francis Edward Stuart, James II's son by his second wife, Mary of Modena. The scene had been set for the later uprisings in Scotland led by the two Stuart pretenders against the Hanoverian kings.
This disagreement over the succession was clearly untenable. In 1706 after months of bitter debate in Edinburgh and lengthy debate elsewhere, Comisssioners for the two Parliaments agreed the Treaty of Union.
Both Parliaments agreed to dissolve themselves and form a Union Parliament which would sit at Westminster from 1707, and there would be a common flag and coinage. Scotland would, however, retain its own established Church and its legal and educational systems.
Until their dismissal in 1710, the political scene was dominated by Marlborough (whose wife enjoyed the influence of a 20-year friendship with the Queen) and the Lord Treasurer Godolphin, who headed a financial team mostly independent of the party factions.
However, in 1711, as a result of a Tory ministry's disagreement with the Whig majority in the House of Lords over the future peace settlement to war in Europe, Anne was persuaded to create peers for party purposes. This represented an important weakening of the royal prerogative.
Anne died in August 1714, a few weeks after the Electress Sophia, so she was succeeded by Sophia's son George, as King George I.