A manuscript of an early work by John Donne, a scurrilous academic joke that could have cost the poet his reputation – and maybe his head – if it had fallen into the wrong hands, has been discovered in a trunk in the archives of Westminster Abbey.

The manuscript may be the earliest surviving copy of what is ostensibly a library catalogue in Latin: the numbered book titles are all invented, and Donne’s list is in fact a string of savage and frequently smutty jokes, many about named contemporary figures.

Book 21 is supposedly The Judges’ Handbook, “containing the many confessions of poisoners given to Justice Manwood, and used by him afterwards in wiping his buttocks, and in examining his evacuations”.

Daniel Starza Smith, of King’s College London, an expert on Donne who has examined the manuscript, said there really was a Justice Manwood, who might well not have appreciated the joke.

Matthew Payne, who holds the historic title of keeper of the muniments at the abbey, found the manuscript after rationing himself to one afternoon a week examining the contents of the tin trunk. Among thousands of tattered fragments, many nibbled centuries ago by mice, he found one complete document: the blackened outer pages have neither title, author, nor any clue how and when they came into the abbey.

The manuscript was discovered in a tin trunk full of uncatalogued scraps. Photograph: Alecsandra Raluca Dragoi/The Guardian

Payne could read the Latin, but identified the contents by transcribing a few lines into Google. “It may not sound very scholarly, but it can often be by far the quickest way of identifying text. Within a few minutes answers were coming in from all over the world, all giving the same source: John Donne’s Catalogus Librorum Satiricus, also known as the Courtier’s Library.”

Donne, best known for metaphysical and deeply erotic poems, is believed to have written and privately circulated the piece – the manuscript is not in his handwriting – in the febrile years leading up to the gunpowder plot, when his own situation was precarious.

He was born into a Roman Catholic family, but eventually became an Anglican cleric and finally dean of St Paul’s. At the time of the catalogue he was viciously satirising the pretentious wealthy whose ranks he had no hope of joining. He had lost his job as secretary to the powerful Sir Thomas Egerton, lord keeper of the great seal, by defying him to marry his niece Anne. Briefly jailed – he announced the news to his wife, pregnant with the first of their 12 children, as “John Donne, Anne Donne, Un-done” – he was then scraping a living as a lawyer.

Payne and Starza Smith will publish an essay on the find in a forthcoming issue of the Review of English Studies. Starza Smith said the catalogue, which wasn’t published until long after Donne’s death in 1631, was the least studied of all his writings.

Donne’s introduction comments bitterly: “We are cast by chance into an age in which nothing is worse than to be openly ignorant, nothing more rare than to be fully learned.”

He urges those anxious to flash their scholarship to seek out books “difficult for others to locate”. With his helpful catalogue, his readers would be enabled “suddenly to spring forth on almost all topics”.

Some of the jokes remain puzzles, but others are blindingly obvious: number 25 deals with Ars Spiritualis Inescandi Mulieres, The Spiritual Art of Enticing Women. Number 23, On the Nothingness of a Fart, was presumably to be shelved near Book 10 dealing with an important area of biblical scholarship, “Concerning the method of emptying the dung from Noah’s Ark”.

“You’ll notice there is a scatological thread here too – all serious satire should have a good fart joke or two,” Starza Smith said.

The manuscript will go on display, free, for one week from 13 November in St Margaret’s Church next door to Westminster Abbey.