Harry, a Troop Commander in the Blues and Royals, confronted the tormentors, warning them they would face severe discipline if they continued their violent threats.
'I could see he wasn't holding back,' said Wharton, who was 21 at the time.
After taking on the gang, Harry briefed a senior officer before returning to assure Wharton the situation had been 'sorted'.
The soldier, who quit the Army earlier this year, said: 'I will always be grateful to Harry and I will never forget what happened. Until he went over and dealt with everything I was on track for a battering.'
The remarkable incident reinforces the view of Harry as an officer with unfailing commitment to the troops under his command. The confrontation came on a training exercise in Canada in September 2008 and is detailed in a book Wharton has written about his ten-year military career, Out In The Army - exclusive extracts from which appear in today's Mail on Sunday.
Yesterday Prince Harry, 28, received widespread praise for his actions. Shadow Defence Secretary Jim Murphy said: 'The whole country will applaud Prince Harry. Our Forces should reflect the modern-day Britain they fight so hard to defend.' Tory MP Colonel Bob Stewart, who led British troops in Bosnia, added: 'Well done Harry, excellent leadership. It's typical of him and typical of young officers in the British Army today, really superb.'
And Ben Summerskill, of the gay and lesbian charity Stonewall, said: 'I take my hat off to him for protecting James Wharton.'
Wharton's book offers the most unvarnished insight yet into Harry's life as a soldier.
The two shared several weeks together in their tank and became firm friends, even swapping details of each other's sex lives. Harry revealed details of his 'first time'.
Wharton, who served in Iraq, also told how Harry said he and Prince William considered themselves to be gay icons.
He said: 'We were on manoeuvres and talking over the intercom.
'Harry happened to mention that he and his brother had been told they were gay icons. I laughed and told him that I didn't think that was the case. He became really adamant saying, "What? What? We are! Our press people told us."
'Harry then asked if he couldn't be a gay icon because he was ginger. It was all very funny.'
Last night, the Ministry of Defence and Buckingham Palace both declined to comment.
- Mail on Sunday