After his return from France Prior became under-secretary of state and succeeded John Locke as a commissioner of trade. In 1701 he sat in Parliament for East Grinstead. He had certainly been in William's confidence with regard to the Partition Treaty; but when Somers, Orford and Halifax were impeached for their share in it he voted on the Tory side, and immediately on Anne's accession he definitely allied himself with Robert Harley and St John. Perhaps in consequence of this for nine years there is no mention of his name in connection with any public transaction. But when the Tories came into power in 1710 Prior's diplomatic abilities were again called into action, and until the death of Anne he held a prominent place in all negotiations with the French court, sometimes as secret agent, sometimes in an equivocal position as ambassador's companion, sometimes as fully accredited but very unpunctually paid ambassador. His share in negotiating the Treaty of Utrecht, of which he is said to have disapproved personally, led to its popular nickname of "Matt's Peace." Prior is also known as a contributor to "The Examiner" newspaper. When the Queen died and the Whigs regained power, he was impeached by Robert Walpole and kept in close custody for two years (1715–1717). In 1709, he had already published a collection of verse. During this imprisonment, maintaining his cheerful philosophy, he wrote his longest humorous poem, "Alma; or, The Progress of the Mind". This, along with his most ambitious work, "Solomon, and other Poems on several Occasions", was published by subscription in 1718. The sum received for this volume (4000 guineas), with a present of £4000 from Lord Harley, enabled him to live in comfort; but he did not long survive his enforced retirement from public life, although he bore his ups and downs with rare equanimity. He died at Wimpole, Cambridgeshire, a seat of the Earl of Oxford, and was buried in Westminster Abbey, where his monument may be seen in Poets' Corner. "A History of his Own Time" was issued by J Bancks in 1740. The book pretended to be derived from Prior's papers, but it is doubtful how far it should be regarded as authentic. Prior's poems show considerable variety, a pleasant scholarship and great executive skill. The most ambitious, i.e. "Solomon", and the paraphrase of "The Nut-Brown Maid", are the least successful.