The two singers made their first live appearance together for 15 years at the Heroes concert at London's Twickenham Stadium.
Robbie - who recently rejoined Gary and his other former bandmates in Take That - performed his hits 'Let Me Entertain You' and 'Come Undone' before introducing his "special treat" to the stage, saying: "This is one of the highlights of my professional career because it is the first time in 15 years. My wife calls him my boyfriend, I call him my captain, but to you he is Gary Barlow."
The two men embraced before performing their duet 'Shame', with the pair repeatedly hugging, sharing a microphone and serenading one another.
Robbie then closed the evening with two of his biggest hits, 'Feel' and 'Angels'.
Boy band The Wanted also performed and admitted they felt overwhelmed by the occasion, which was held to raise money for armed forces charity Help for Heroes.
Singer Nathan Sykes said: "I feel a bit useless to be honest. Look at all those artists here who have sold millions of records and then there's us - we've only sold a few.
"I don't normally get nervous but I've been a nervous wreck today."
Veteran crooner Sir Tom Jones also performed and was delighted to show his support for the charity.
He told BANG Showbiz: "It's very important that we support these people. They go off to fight for us, so we should support them and be able to say thank you very much.
"It's fantastic, the show is great."