Drag act on the HMS Queen Elizabeth, 1913
Drag acts on the HMS Queen Elizabeth, 1913National Maritime Museum

For 200 years from 1627 naval buggery was a hanging offence, and it wasn't until the 1967 Sexual Offences act decriminalised homosexual acts in private between two men over the age of 21. But homosexuality on ships was still illegal in the Merchant Navy until 1994 and in the armed forces until 1999. However, today the Royal Navy has recently been announced as number 10 in Stonewall's top 100 gay-friendly employers.

LGBT history month
The Middy on the Stage, 1887National Maritime Museum

It wasn't so long ago that men were hanged for having sex with another man. In 1807, First lieutenant William Berry of the Salvador del Mundo, was brought up on charges which the Morning Chronicle says was a "horrid and abominable crime which delicacy forbids me to name".

Berry was court martialled and sentenced to be hanged by the neck until dead. The Times reported on his manner of death. "On the blue cap being put over his face, the fatal bow-gun was fired, and he was immediately run up to the starboard fore-yard-arm, with a 32lb. shot tied to his legs. Unfortunately the knot had got round under his chin, which caused great convulsions for a quarter of an hour. After being suspended the usual time, he was lowered into his coffin."

The penalties for women discovered cross-dressing were much less severe: they were not imprisoned although some did appear before magistrates. In the 19th century, it was possible to gain a permit for dressing in masculine clothes and this protected women from arrest.

Sailors dancing at sea
Sailors dancing at seaNational Maritime Museum, London

Women were attracted to cross-dressing by a number of circumstances, such as economic need or work in occupations otherwise reserved for men. Some even used cross-dressing to express patriotic fervour by joining the military, according to Transgender History & Geography: "Of 119 women documented as living as men in Denmark between 1550 – 1839, most become sailors or soldiers."

Piracy also seems to have attracted a number of cross-dressing women. Anne Bonny and Mary Read were members of Calico Jack Rackham's crew, which operated in the Caribbean. Their exploits were documented in A General History Of Robberies And Murders Of The Most Notorious Pirates. Originally published in 1724, this famous account of the most notorious pirates of the day was an immediate success. It was written by the mysterious Captain Charles Johnson, which some historians argue is a nom de plume for Robinson Crusoe author Daniel Defoe.

Read was "very profligate", said one of her victims, "cursing and swearing much", wielding a machete and pistol. Loose clothing hid her breasts and as her mates were mostly in their teens and early twenties, no one thought her lack of facial hair was unusual. It's also likely she suffered from stress and poor diet while serving in the army, factors that could have interrupted or paused her menstrual cycle.

Mary Read
Female pirate Mary Read killing her antagonistWikipedia: The Pirates Own Book, 1842

The fame of cross-dressing women was such that they were written about in songs, referred to as the transvestite ballads, or warrior women ballads. The Handsome Cabin Boy was written in the 19th century and tells of a young woman wanting to see the world, so she disguises herself as a captain's cabin boy.

The Handsome Cabin Boy, c19th century

And the captain's wife, she being on board,

She seemed in great joy

To think her husband had engaged

Such a handsome cabin boy

And now and then she's slip him a kiss

And would have liked to toy,

But it was the captain found out the secret

Of this handsome cabin boy

When women were discovered to have dressed as men, they were treated "chivalrously, as curiosities because they had worked so hard and were as brave as men".

"It up-ended people's ideas about the little woman and the 'frail sex', and about men being the only people who should be at sea," says Dr Jo Stanley, co-author of Hello Sailor: The Hidden History Of Gay Life At Sea.

As part of LGBT History Month author and lesbian, gay, bisexual and transgender (LGBT) historian Stanley discusses queer history in the navy on 20 February at the National Maritime Museum in London.

Sara Wajid, senior manager of public programmes at the National Maritime Museum, says: "Away from land norms for months, unlike planes and trains, there was time for relationships and new ways of orienting yourself to develop. 'Everything's gay when you're under way' became a common adage."