The 27-year-old music megastar penned the 2015 hit for Justin, with the help of Benny Blanco, and he took the opportunity to play it for his fans at the special event.
Introducing the track, Ed said: ''Here's a song that I never really play and I don't play it because I don't sing it. It's a song that I write and the guy that sings it probably does a better job than I will...''
Ed had been invited to play by his friend Jordan Stephens, who organised the show to highlight the need for open and honest conversations around mental health issues in conjunction with his #IAMWHOLE campaign in partnership with mental health charities YMCA, The Mix and Campaign Against Living Miserably (CALM).
And the BRIT Awards winner took time out to thank Rizzle Kicks star Jordan and everyone else who gave up their time for free to put on the concert for such an important cause, such as photographer Philip Sansom (@phixlondon) who shot the sets for no charge.
Before closing his set with 'Shape of You', the singer/songwriter - who also played his hits 'Castle on the Hill', 'The A-Team', 'Perfect' and 'Thinking Out Loud' - told the crowd: ''Before I go, a reminder this is a charity event so there's a lot of people here who have given up their time for free to make sure this could happen so thanks so much to them. Thanks to Jordan and the whole team.''
Ed was joined on the bill by an impressive array of acts, including Nothing But Thieves, Anne-Marie, Louis Berry, Olly Murs, Ella Eyre, Professor Green and spoken word artist Hussain Manawer, who moved the audience with an emotional poem about the death of his mother.
Introducing his track 'Talking To Myself', Olly explained that the lyrics deal with his own struggles with anxiety and panic attacks.
He said: ''I've had my struggles, I wrote this song on my album it's called 'Talking To Myself'. Do you ever talk to yourself? It's OK to say you have anxiety, have panic attacks. Talk to someone, tell them.''
James Arthur - who has been open about his struggle with depression and anxiety - closed proceedings with an acoustic set and again used the platform to encourage anyone who has mental health problems to not be afraid to be honest about it with the people whom they love.
He said: ''I like to think I'm an ambassador for this subject, I've suffered massively myself and the most important thing I've learned is that it's OK not to be OK. It's huge to just accept that and talk about it and help other people.''
They might sound like they're from the 70s, but they way they roll is very 2020.
What's new in the music world this week?
'U Kin B the Sun' is an album rich in texture and depth and one that quite obviously, and unapologetically, plays to Frazey Ford's strengths.
Listen to their new single 'Small Change'.
Everything you ever needed to know about Viking metal.
3TEETH hit Leeds for the first time with support from British artist PIG.
This will make you want to walk amongst the skyscrapers.
As it's been 12 years since the last Bridget Jones movie, expectations aren't too high...
Bridget has always known how to get herself into a muddle - catastrophic muddles at...
After battling the dating scene and finally finding love with Mark Darcy, Bridget Jones is...
In July of 2015, Ed Sheeran played his biggest gigs to date, selling out Wembley...