Prince Harry

Prince Harry intervened to prevent a homophobic attack on a soldier, a new book reveals.

Trooper James Wharton describes being confronted by "six extremely angry infantry sergeants" from a rival regiment when he was 21 and on a training exercise in Canada.

He writes that he climbed into the tank turret with Prince Harry, his commanding officer, and "talked him through exactly what had happened. He had a complete look of bewilderment on his face.

"I didn't hold back, I told him everything that had gone on. I couldn't stop the tears welling up in my eyes. He said: 'Right, I am going to sort this shit out once and for all'," Wharton writes in Out in the Army.

"Harry climbed out of the tank and started having a go. I worried he was about to make the whole thing worse, but he wasn't holding back.

"Prince Harry was sticking up for me and putting a stop to the trouble. I had been on track for a battering and had been rescued. He came back 10 minutes later and told me the problem had been 'sorted'."

In 2009, Wharton became the first openly gay soldier to feature on the cover of armed forces magazine Soldier since the ban on homosexuals serving in the military was lifted in 2000.

Wharton writes that when he met Harry he "looked at a photograph of me and my boyfriend on my barrack room wall - and told me we looked good together."

Later, Wharton recounts that in a conversation with another soldier and Harry, "He told us both an extraordinary tale about the first time he'd had sex, it was fascinating."

Talking to the Mail on Sunday Tory MP Colonel Bob Stewart, who led British troops in Bosnia, said: "Well done Harry, excellent leadership. It's typical of him and typical of young officers in the British Army today, really superb."

Ben Summerskill, of the gay and lesbian charity Stonewall, said: "I take my hat off to him for protecting James Wharton."