A British military veteran, who was openly gay when he served in the army, has revealed that Prince Harry once defended him against homophobic abuse from other soldiers.

James Wharton served with Harry, also known as the Duke of Sussex, in the British army back in 2008 when they were deployed to Canada. Harry, who was "quite offended" by the anti-gay remarks, was Wharton's tank commander.

"I had got myself into a bit of a situation with some soldiers from another regiment and, essentially, they didn't like the fact I was gay," said Wharton, who recounted the story in an interview with the U.K. site Forces News.

Get Breaking News Delivered to Your Inbox

"They were sort of chest poking me and making me feel quite uncomfortable. I got into my tank where Prince Harry was doing something, and he could see that I was clearly affected by something and he asked me what the problem was," Wharton recalled.

"I told him that there were a couple of soldiers outside who weren't very happy with the fact I was gay. So, quite offended that his gunner was being picked on by these people, Prince Harry went out and saw these soldiers and spoke to them, and the problem went away," Wharton said.

The former soldier said that once Prince Harry "told them off," the taunting stopped.

"He knew how to do his job, he was skilled, he took the time to know his people, he wasn't afraid to get himself involved with things that were going on," said Wharton.

Prince Harry served in the army for ten years, which included two tours in Afghanistan.

He has been open about his support for the LGBTQ+ community. Last year, the Duke and Duchess of Sussex paid tribute to the community on their official Instagram account. "We proudly shine a light on PRIDE," they wrote. "We stand with you and support you."

Prince Harry's wife Meghan, Duchess of Sussex, is currently in Canada following the couple's decision to step back from their "senior" royal roles. In their announcement, they said that they will be dividing their time between Britain and North America in order to raise their son Archie "with an appreciation for the royal tradition into which he was born, while also providing our family with the space to focus on the next chapter."

Queen Elizabeth II said she and the royal family "are entirely supportive of Harry and Meghan's desire to create a new life as a young family," even though "we would have preferred them to remain full-time working Members of the Royal Family."