A 17th-century sailor’s confession about a rape, of which he became so ashamed that he sought to cover it up for ever, has been exposed by conservation workers who discovered the note hidden under a rewritten version in his journal.

The confession went unseen for more than 300 years because the sailor pasted his second account so neatly over the top of the original that scholars missed it.

Edward Barlow’s lavishly illustrated journal of his extraordinary life is now held at the National Maritime Museum in Greenwich. The farm worker’s son joined the navy as a child, sailed as a teenager on the same ship as Samuel Pepys to bring Charles II back to England, survived several shipwrecks and captivity, and eventually rose to become a captain.

He began the journal when taken prisoner in the Dutch East Indies in 1671, and continued it when he got safely back to England. He originally wrote an excruciatingly frank account of his rape of Mary Symons, a young female servant in a house where he was lodging, an encounter he admitted was “much against her will, for indeed she was asleep but being gotten into the bed I could not easily be persuaded out again, and I confess that I did more than what was lawful or civil, but not in that manner that I could ever judge or, in the least, think that she should prove with child, for I take God to witness I did not enter her body, all though I did attempt something in that nature”.

Barlow inserted a line of warning: “I found by her that women’s wombs are of an attractive quality and dangerous for a young man to meddle with.”

He continued that though he wrote “a loving letter”, he wanted to “forget her and blot her out of my remembrance … as I had done with some before”. However, when his ship returned to England from Jamaica, he agreed to meet Symons and found her “weeping most pitifully and saying she was undone”.

Against the advice of friends urging him that he had a good chance of finding a rich wife, Barlow married her in Deal, “a very decent marriage where we had several people of good repute”. The union celebrated with a two-day party that cost him £10.

Their child was stillborn while Barlow was at sea, but they went on to have several more children and, despite initial doubts, he heaped praise on his wife: “Had I searched England over for a mate I could not have met with one more obliging and ready to do any thing that should give me content.”

It was Paul Cook, a senior paper conservator at the National Maritime Museum in Greenwich, who spotted the newly pasted page and exposed Barlow’s shame.

Cook was told the manuscriptwas “a problem” when he joined the museum in 1985. The document was bought at a country house sale in the early 20th century and partly published by the scholar Basil Lubbock, who then presented it to the museum.

A page from Edward Barlow’s journal, written between 1659 and 1703. Photograph: Jon Stokes/National Maritime Museum, Greenwich, London

He has spent nine years working on it, reversing the damage caused by previous attempted repairs. The final effort in the 1970s, using a technique Cook says was then widely accepted, involved pasting a fine silk gauze to strengthen the pages – but it was in fact damaging Barlow’s illustrations, including battles at sea and a shark devouring a naked man, whales, an elephant and a rhinoceros.

Cook became the first person in more than 300 years to read Barlow’s original words, hidden under the rewritten version, which included the weeping woman on the shore but omitted the account of the rape. Instead, Barlow wrote: “I had in part promised her at London that I would marry her … having had a little more than ordinary familiarity with her”.

Roberth Blyth, a senior curator at Greenwich, who has included pages from the journal in the Tudor and Stuart navy gallery opening this week, thinks Barlow probably came back from sea, reread his journal and was horrified at how honest he had been.

“By then, he is a respectably married man, with a house and children, and he must have thought: ‘is this really the account I wish to leave of myself to history? With every voyage there’s a chance I may never return, and is this what I want my children to read about their mother?’”

Barlow’s spelling and punctuation are erratic, but the handwriting is beautiful, swirling across tightly ruled lines on high-quality paper, which Blyth thinks must have been pilfered from stores.

“The official account is that he learned to read and write while a prisoner, where he certainly would have had time to start a journal, but that is what is technically known as bollocks,” Blyth said. “Nobody ever taught themselves to write like that – he must already have been at least partly literate, which was rare enough for an ordinary seaman.”

Fate caught up on Barlow in 1706, when the ship he finally commanded, the Liampo, was wrecked off Mozambique. His bequests included a silver supper dish, two cups, four small teaspoons – and a secret that would be kept for centuries.

• Pages from Barlow’s journal and a digitised version of the manuscript will go on display for the first time at the National Maritime Museum in one of four galleries opening on 20 September.