The Duke and Duchess of Cambridge attended The X Factor judges' concert with Prince Charles and his wife Camilla, which was held in aid of royal charities.
Moments before Barlow stepped out on stage to entertain his audience, the Take That frontman joked with Wills and Kate, telling the Prince: "I hope you enjoy tonight and I hope it's not too loud."
According to the BBC, William then joked: "The louder the better, the louder the better."
At the start of his performance, Gary also greeted his special guests stating: "Good evening to our beautiful royal family. All the money goes to a fantastic cause so we're killing two birds with one stone."
The 40-year old then powered through a set including tracks A Million Love Songs and Pray, as he was also joined on stage by Jason Donovan, Olly Murs, Lulu and his X Factor protégé Marcus Collins - who was unable to perform the night before due to a throat infection.
Speaking after the show, Barlow told the BBC: "It's been great. Both nights were amazing; people have been buying lots of merchandise which all goes to a good cause."
The event raised finds for both the Prince's Trust and The Foundation of Prince William and Prince Harry - with Gary adding to The Sun that he "wasn't nervous" performing for his royal guests.
Watch MTV News on the hour every hour on MTV - Sky Channel 126 and Virgin Channel 134