The monarchy was restored to Charles II in 1660. Marvell avoided punishment for his own co-operation with republicanism, and he helped convince the government of Charles II not to execute John Milton for his antimonarchical writings and revolutionary activities. The closeness of the relationship between the two former colleagues is indicated by the fact that Marvell contributed an eloquent prefatory poem, entitled "On Mr. Milton's Paradise Lost", to the second edition of Milton's epic Paradise Lost. According to a biographer: "Skilled in the arts of self-preservation, he was not a toady."
In 1661 Marvell was re-elected MP for Hull in the Cavalier Parliament. He eventually came to write several long and bitterly satirical verses against the corruption of the court. Although circulated in manuscript form, some finding anonymous publication in print, they were too politically sensitive and thus dangerous to be published under his name until well after his death. Marvell took up opposition to the 'court party', and satirised them anonymously. In his longest verse satire, Last Instructions to a Painter, written in 1667, Marvell responded to the political corruption that had contributed to English failures during the Second Anglo-Dutch War. The poem did not find print publication until after the Revolution of 1688–9. The poem instructs an imaginary painter how to picture the state without a proper navy to defend them, led by men without intelligence or courage, a corrupt and dissolute court, and dishonest officials. Of another such satire, Samuel Pepys, himself a government official, commented in his diary, "Here I met with a fourth Advice to a Painter upon the coming in of the Dutch and the End of the War, that made my heart ake to read, it being too sharp and so true."
From 1659 until his death in 1678, Marvell was serving as London agent for the Hull Trinity House, a shipmasters' guild. He went on two missions to the continent, one to the Dutch Republic and the other encompassing Russia, Sweden, and Denmark. He spent some time living in a cottage on Highgate Hill in north London, where his time in the area is recorded by a bronze plaque that bears the following inscription:
Four feet below this spot is the stone step, formerly the entrance to the cottage in which lived Andrew Marvell, poet, wit, and satirist; colleague with John Milton in the foreign or Latin secretaryship during the Commonwealth; and for about twenty years M.P. for Hull. Born at Winestead, Yorkshire, 31st March, 1621, died in London, 18th August, 1678, and buried in the church of St. Giles-in-the-Fields. This memorial is placed here by the London County Council, December, 1898.
A floral sundial  in the nearby Lauderdale House bears an inscription quoting lines from of his poem "The Garden". He died suddenly in 1678, while in attendance at a popular meeting of his old constituents at Hull. His health had previously been remarkably good; and it was supposed by many that he was poisoned by some of his political or clerical enemies. Marvell was buried in the church of St Giles in the Fields in central London. His monument, erected by his grateful constituency, bears the following inscription:
Near this place lyeth the body of Andrew Marvell, Esq., a man so endowed by Nature, so improved by Education, Study, and Travel, so consummated by Experience, that, joining the peculiar graces of Wit and Learning, with a singular penetration and strength of judgment; and exercising all these in the whole course of his life, with an unutterable steadiness in the ways of Virtue, he became the ornament and example of his age, beloved by good men, feared by bad, admired by all, though imitated by few; and scarce paralleled by any. But a Tombstone can neither contain his character, nor is Marble necessary to transmit it to posterity; it is engraved in the minds of this generation, and will be always legible in his inimitable writings, nevertheless. He having served twenty years successfully in Parliament, and that with such Wisdom, Dexterity, and Courage, as becomes a true Patriot, the town of Kingston-upon-Hull, from whence he was deputed to that Assembly, lamenting in his death the public loss, have erected this Monument of their Grief and their Gratitude, 1688.
It may be noted that his epitaph pays more tribute to his political career than his poetry.