The position of the king in England was made more difficult by the lamented death of Queen Mary on January 2,1695. William had become deeply attached to his wife during these last years, and for a time he was prostrated by grief. But a strong sense of public duty roused him from his depression; and the campaign of 1695 was signalised by the most brilliant military exploit of his life, the recapture of Namur. That town, strong by its natural position, had been fortified by Vauban with all the resources of engineering skill, and was defended by a powerful garrison commanded by Marshal Boufflers. But William had with him the famous Coehoorn, in scientific siege-warfare the equal of Vauban himself. At the end of a month the town of Namur was taken, but Boufflers withdrew to the citadel. Villeroy, at the head of an army of 90,000 men, did his utmost to compel the king to raise the siege by threatening Brussels; but a strong allied force watched his movements and successfully barred his approach to Namur. At last, on September 5, Boufflers capitulated after a gallant defence on the condition that he and his troops should march out with all the honours of war.
The campaign of 1696 was marked by no event of importance; indeed both sides were thoroughly tired out by the protracted and inconclusive contest. Moreover the failing health of Charles II of Spain threatened to open out at any moment the vital question of the succession to the Spanish throne. Louis XIV, William III and the emperor were all keenly alive to the importance of the issue, and wished to have their hands free in order to prepare for a settlement, either by diplomatic means or by a fresh appeal to arms. But peace was the immediate need, and overtures were privately made by the French king to each of the allied powers in 1696. At last it was agreed that plenipotentiaries from all the belligerents should meet in congress at Ryswyck near the Hague with the Swedish Count Lilienrot as mediator. The congress was opened on May 9, 1697, but many weeks elapsed before the representatives of the various powers settled down to business. Heinsius and Dijkveld were the two chief Dutch negotiators. The emperor, when the other powers had come to terms, refused to accede; and finally England, Spain and the United Provinces determined to conclude a separate peace. It was signed on September 20 and was based upon the treaties of Nijmwegen and Muenster. France, having ulterior motives, had been conciliatory. Strasburg was retained, but most of the French conquests were given up. William was recognised as King of England, and the Principality of Orange was restored to him. With the Dutch a commercial treaty was concluded for twenty-five years on favourable terms.