One summer’s day long ago, a government bureaucrat recorded a resolution to set his affairs in good order, “the season growing so sickly that it is much to be feared how a man can ’scape having a share in it — for which the good Lord God bless me, or be fitted to receive it”.

The bureaucrat was Samuel Pepys, and the year was 1665. Bubonic plague raged, killing thousands a week in a London with a population of only 450,000.

Pepys’s great diary lays bare the terrors, horrors and abyss of ignorance prevailing almost four centuries ago, matching those that threaten our own society. Only the rates of mortality, God be thanked — the words Pepys would have used — are vastly lower.

He was 32, a tailor’s son born in Salisbury Court, off Fleet Street, whose brains and industry enabled him to study at Cambridge, to get a start in government service under the Commonwealth, then to prosper following the Restoration. He married a French wife named Elizabeth, became a protégé of the Earl of Sandwich and in 1665 rose to be surveyor of victuals for the navy and secretary of the Tangier committee.

Plagues carried by rat-borne fleas struck European cities every decade or two: those of 1592, 1603, 1625 and 1636 had been notably bad — 1625’s killed 40,000 Londoners. From the outset, however, 1665 promised worse. Pepys recorded the plague’s presence in Amsterdam, then on April 30 first mentioned its arrival in London: “Great fears of the sickenesse here in the City, its being said that two or three houses are already shut up.”

The next mention came on May 28, as a footnote to an account of a love intrigue. The 17-year-old Lord Rochester had eloped with a teenage heiress, Elizabeth Malet. Pepys’s patroness, Lady Sandwich, was much interested, because she wanted her own son to marry little Ms Malet.

“Great fears of the sickenesse here in the City, its being said that two or three houses are already shut up.”

The diarist wrote: “My poor Lady, who is afeared of the sickness and resolved to be gone to the country, is forced to stay in town a day or two or three, to see the event of it.”

Here was an important social clue about plagues: they fell most heavily upon the poor, who had no means of escape from their crowded, filthy city hovels. The rich, by contrast, fled to country estates. In 1665 the king and court decamped first to Hampton Court, then to Oxford.

Sessions of parliament were postponed, theatres stayed closed until November 1666.

The fashion for wigs suffered a temporary eclipse because of fears that they were made from the hair of plague victims. Pepys lamented the near-disappearance of passage boats from the Thames because so many watermen were dead. Grass grew among the cobbles in Whitehall for lack of workmen to remove it.

One notable stay-behind in the City was the great financier Sir Martin Noell, who expired on September 28. Ten days later Pepys reported that Noell’s widow was dead with grief for her husband, “but it seems that nobody can make anything of his estate, whether he be dead worth anything or no, having dealt in so many things, public and private, as nobody can understand whereabouts his estate is which is the fate of these great dealers in everything”. The diarist’s tone is sententious, but also vividly 21st century — think hedge fund managers.

Pepys described a grim walk to the Tower: “Lord, how empty the streets are, and melancholy, so many poor sick people, full of sores, and so many sad stories overheard as I walk, everybody talking of this dead, and that man sick, and so many in this place, and so many in that. And they tell me that in Westminster there is never a physician. And but one apothecary left, all being dead.” Pepys’s own man, Dr Burnett, perished after performing a post-mortem examination on a plague victim.

In August Pepys dispatched his wife and her household to rural sanctuary in Woolwich, locking up their spacious house in Seething Lane. He also persuaded the King that the Navy Office should move to Greenwich.

Yet he himself continued to travel often into London, and to take extraordinary risks, such as visiting Moorfields’ huge plague burial pits, to satisfy his consuming curiosity.

“Lord, how empty the streets are, and melancholy, so many poor sick people, full of sores, and so many sad stories overheard as I walk.”

He worked on for a time at the Seething Lane Navy office, telling a colleague, an old Cavalier who decamped to Greenwich: “You, Sir, took your turn at the sword. I must not therefore grudge to take mine at the pestilence.”

Why did he not succumb, as he often feared must happen? There has been speculation that he had fluke immunity: Clare Tomalin, in her splendid biography, notes that certain people lack appeal to fleas. Pepys described how, when he shared a bed with a friend in Portsmouth in 1662, “all the fleas came to him and not to me”.

Word of mouth carried most tidings, and rumour raged. When Pepys disappeared from London for a time to visit the fleet on official business, he returned to write: “I hear by everybody how much my poor Lord of Sandwich was concerned for me during my silence awhile, lest I had been dead of the plague in this sickly time.” In another entry he recorded: “I was in great trouble all this day for my boy Tom, who went to Greenwich yesterday by my order and came not home till tonight for fear of the plague. But he did come tonight.”

Among quack remedies, he chewed tobacco and was given by his friend Lady Carteret a bottle of “Plague Water”, probably made with herbs, though he does not record whether he drank it. On September 6 he watched fires burning in the street, “as it is through the whole City, by the Lord Mayor’s order”. The City had appointed physicians to advise on palliatives: woodsmoke was their first suggestion.

It is unsurprising that the lord mayor was desperate: in the last week of August more than 6,000 deaths were attributed to plague, and Pepys remarked that this was probably an underestimate, “partly from the poor that cannot be taken notice of through the greatness of the number, and partly from the Quakers and others that will not have any [church] bell ring for them”.

“It troubled me to pass by Come Farme, where about 21 people have died of the plague and three or four days since I saw a dead corpse in a Coffin lie in the close unburied —and a watch is constantly kept there, night and days, to keep the people in.” Here was an early, brutal lockdown, “the plague making us cruel as dogs one to another”.

Yet amid this great catalogue of woe, which persisted until the year’s end, part of the fascination of Pepys’s account is that his spasms of fear and dismay are interspersed with far lengthier passages about his happiness. He was rising fast in the public service, becoming a modestly wealthy man who continued to indulge his passions for buying clothes, books, a 12ft telescope.

Here was an early, brutal lockdown, “the plague making us cruel as dogs one to another.”

He wrote deploring the mass burials, but concluded that entry with the declaration “and so bed, mighty merry”. Passionately gregarious, he continued to revel in his evenings of music, to carouse in taverns, and of course to dally with every woman who would give him countenance. In September he wrote: “I do end this month with the greatest content, and may say that these last three months, for joy, health and profit, have been much the greatest that ever I received in all my life — having nothing but the consideration of the sickliness of the season to mortify me. For all which, the Lord God be praised.”

At least 70,000 Londoners had died, about one in six of the capital’s inhabitants, yet on New Year’s Eve Pepys was still celebrating his prosperity. His wife was back in Seething Lane, and “to our great joy the town fills apace, and shops begin to be open again”.

It is important to recall that the plague was only one among a procession of nigh-apocalyptic experiences that Pepys’s generation lived through: the Civil War, Charles I’s execution in 1649, the 1660 transition from Commonwealth to restored kingship.

Scarcely had Londoners recovered their spirits from the plague when the 1666 Great Fire devastated the city. In the following year a Dutch fleet sailed up the Medway, its cannon audible at Court, harrowing and humiliating the Royal Navy.

Through all these desperate events Pepys and many of his fellow-countrymen contrived successful lives. His diary is sometimes mocked for its confessions of cupidity and debauchery. Yet it is, above all, a monument to courage, the triumph of the human spirit.

Fearsome though our own times seem today, an incomparably smaller portion of fortitude is demanded of us than of Pepys and his contemporaries. No wonder that, among even the most rational of them, fear of God was a towering sensation.