Move introduced in bid to foster greater tolerance and diversity within the military, but recruits will be allowed to opt out of detailing their orientation with a ‘prefer not to say’ option. Details will be stored by the MoD but kept anonymous.

When the UK took the step of allowing gay men and women to serve openly in the armed forces in 2000, public opinion was in favour but the armed forces themselves were not. However this action is seen as a major step forward in preventing homophobic attitudes.

James Wharton, 28, suffered beatings in the Household ­Cavalry’s Blues and Royals for being openly gay. He was famously saved from one attack by Prince Harry. The Prince stepped in to save Trooper James Wharton after he was confronted by six soldiers threatening to ‘batter’ him.

The ex-Lance Corporal said: “It’s fantastic news. But it’s important troops don’t have to reveal sexual preferences. I wasn’t ready to do that.”

Recruits will also be invited to provide additional information on how open they feel they can be regarding their sexual orientation. The information will not be visible on individual personal records or to chain of command or managers, and will be anonymised before being collated to ensure no one can be identified by their personal diversity information.

Charity Stonewall, which campaigned against the discrimination of gay soldiers, welcomed the MoD move. Spokeswoman Mandy McBain said: “By knowing more about personnel, the forces can support them better.”

The new procedures were introduced last November but have only recently been revealed. The armed forces said they believe the new policy will shed new light on their workforce and help create a more inclusive organisation where everyone feels valued.