A tearful Roger Federer waved goodbye to professional tennis after teaming up with fellow great Rafael Nadal on an emotional night at the Laver Cup.
The 41-year-old received a long ovation after walking off court for the final time as he retired as a professional.
The Swiss, who won 20 Grand Slam singles titles, is considered one of the best players in tennis history.
"It's been a wonderful day. I'm happy, not sad. It feels great to be here. I'm happy I made it through," he said.
Federer cried as he hugged Nadal and other players, then took acclaim from the thousands of fans who chanted his name at the O2 Arena in London.
Nadal also could not hold back the tears. The 36-year-old Spaniard cried as he sat alongside Federer while the pair listened to British singer Ellie Goulding, who rounded off a memorable night with a performance.
Federer and Nadal - for so long rivals at the top of the men's game - joined forces to play doubles against American pair Jack Sock and Frances Tiafoe in the annual team event between Europe and the rest of the world.
Despite Federer not having played competitively for over a year, the veteran duo pushed Sock and Tiafoe before losing 4-6 7-6 (7-2) 11-9 as Team World levelled at 2-2 at the end of play on the opening day.
Federer and Nadal - affectionately nicknamed 'Fedal' - almost won it. The pair had a match point at 9-8 in the decider, but Federer could only lunge for a forehand which he pushed into the net.
The defeat brought the former world number one's 25-year professional career to a close after his 1,750th competitive match across singles and doubles.
"It's been the perfect journey. I'd do it all again," said Federer as tried to hold back tears during his on-court speech.
Federer's career had long been on the downward slope, having battled a knee injury for the past two years and needing three operations in a bid to overcome the problem.
He had not played a competitive match since losing to Poland's Hubert Hurkacz in the quarter-finals at Wimbledon last year.
Despite being restricted to only three of the 11 Grand Slams staged since the start of 2020, he hoped as recently as July he would still be able to return to the major tournaments.
But, after a scan brought further bad news, Federer announced last week he was going to retire because his "body's message lately has been clear".
Federer had talked about throwing a party to mark his final match, saying he wanted the occasion to be fun and not funereal.
As he wished, there was a celebratory atmosphere in the 17,500-capacity arena.
Watched by his wife Mirka, their four children, plus his parents Robert and Lynette, Federer's every move was greeted with cheers containing a mixture of euphoria and empathy.
The family joined him on court afterwards during a poignant celebration, which saw many more tears and Federer hoisted aloft by his fellow players.
"Everyone's here, the boys and girls. My wife has been so supportive. She could have stopped me a long, long time ago but she didn't," said Federer.
"She kept me going and allowed me to play, so it's amazing - thank you."
The presence of several tennis legends including Rod Laver, along with celebrities including Hollywood actor Hugh Grant and Vogue editor Anna Wintour, added to the occasion.
Current world number ones, Carlos Alcaraz and Iga Swiatek, tweeted their range of emotions as they watched the match on the television, as did Federer's Swiss Davis Cup team-mate Stan Wawrinka.
Federer was only fit enough to play doubles because of a knee injury and his movement was limited.
Afterwards, he joked he was happy to get through the match without pulling a muscle in his calf or back.
"Being with the guys and having family and friends, I didn't feel the stress so much even if I felt something would go during the match," Federer said.
"I am so glad I made it through and the match was great. I couldn't be happier."
Federer and Nadal have been long-time rivals and opponents in some of the sport's greatest moments, but have also become good friends
What Federer means to tennis and his fans
Not only did Federer push boundaries with his play and set a plethora of records, he also became one of the most popular players tennis has ever seen.
His style of play - described as balletic, graceful and fluent - has endeared him to millions of fans across the world. So too has his polite and charming personality.
Federer transcends tennis. For some, he almost transcends the world.
Before the match, you could see hundreds of fans filing into the arena wearing Federer-branded clothing and accessories.
Hats, T-shirts, scarves, banners and even custom-made earrings. All red and white - the national colours of Switzerland - with most emblazoned with the initials of their hero: RF.
A few Swiss flags were also draped around the indoor arena.
One Federer super-fan at the O2 Arena, Robert Springer from Poland, described his idol as the 'King of Tennis".
"He has quality, empathy, a super sportsman, a gentleman and a good father. Plus he always has time for his fans. He's the one and only," Robert told BBC Sport.
Tickets for the night session on Friday were already sold out before Federer announced last week he was going to retire after the annual team event.
Initially they were available from between £40 and £510. Following the news, they were being offered on resale platforms for over £1,000 each.
Despite the match finishing at 00:26 BST, with the celebrations continuing for about another half an hour, few of those present left before the end.
"Thank you everybody. I've had so many people cheer me on and you guys here tonight mean the world," said Federer, who later added he was "really scared" about speaking on court because he knew he would get emotional.
"This is not the end-end, you know, life goes on. I'm healthy, I'm happy, everything's great, and this is just a moment in time."
BDST: 1355 HRS, SEP 24, 2022