Roger Federer described his tennis career as a "perfect journey" despite being denied a fairytale ending with a doubles defeat at the Laver Cup early on Saturday alongside Rafael Nadal.
The 20-time Grand Slam champion has not played since the 2021 Wimbledon quarter-finals because of a knee injury and last week announced his retirement aged 41.
Playing with long-time friend and rival Nadal, the two former world number ones won the first set to the delight of a feverish, partisan crowd, but the Americans rallied to win 4-6, 7-6 (7/2), 11-9.
The result meant Team Europe were locked at 2-2 with Team World at the end of the opening day of the Ryder Cup-style event.
"We'll get through this somehow, will we? Right?" Federer said with a cracked voice during an emotional post-match farewell on court.
"I'm happy, I'm not sad. It feels great to be here and I enjoyed tying my shoes one more time. Everything was the last time. The match was great, I couldn't be happier. It's been wonderful."
Federer has enjoyed a storied rivalry with Spain's Nadal, 36, over nearly two decades -- together they have won 42 Grand Slam singles titles in a golden era for the men's game.
There was a huge roar and standing ovation as the Swiss great and Nadal came onto the black court, dressed in blue shirts and white shorts, both wearing white headbands.
Both doubles pairings held serve fairly comfortably at the start of the match, with cries of "Let's go Roger, let's go" breaking out at 3-3.
Federer and Nadal seized on their first break point in the 10th game, winning the first set when Sock netted with a backhand to huge cheers.
The Americans levelled the match by taking the second set tie-break with ease.
In a nerve-shredding match tie-break, Federer was unable to serve out for the match at 9-8, with Tiafoe and Sock winning the next three points to emerge victorious.
The Swiss was overcome with emotion afterwards, hugging teammate Nadal and waving to the crowd.
"Playing with Rafa on the same team, and having the guys, everybody here, all the legends... thank you," said Federer, who was joined by his parents, wife Mirka and their four children.
"It does feel like a celebration to me," he added. "I wanted to feel like this at the end and it is exactly what I hoped for, so thank you. It has been a perfect journey and I would do it all over again."
Nadal, who was also visibly emotional, said it had been difficult to handle the intensity of the occasion.
"For me, it has been a huge honour to be a part of this amazing moment of the history of our sport, and at the same time a lot of years sharing a lot of things together," said the Spaniard.
"When Roger leaves the tour an important part of my life is leaving too."
The six-strong Team Europe also includes Novak Djokovic and Andy Murray -- the other two members of the so-called "Big Four" who have dominated the men's game for so many years.
Italy's Matteo Berrettini will take Federer's place over the weekend as an alternate, with the Swiss great opting not to play singles matches.
The Swiss is leaving the stage 19 years after winning his first Grand Slam title at Wimbledon in 2003.
He retires with a men's record of eight Wimbledon crowns, 103 titles overall and more than $130 million in prize money, all won with a game defined by a rare elegance and precision.
Nadal (22) and Djokovic (21) have both surpassed Federer's tally of Grand Slam titles but Team World captain John McEnroe said Federer's retirement would leave "a void that will never be filled".