Eight-time champion Roger Federer avoided a huge Wimbledon upset as injury robbed France's Adrian Mannarino of the chance to earn a memorable win.
Sixth seed Federer, 39, trailed 6-4 6-7 (3-7) 3-6 4-2 when Mannarino slipped and injured his knee.
The world number 41 battled on and lost the fourth set, then retired after one point in the decider.
A sympathetic Centre Court crowd gave a heartfelt ovation as Mannarino, on his 33rd birthday, limped off court.
It was a cruel blow for Mannarino, who had played brilliantly in the second and third sets to put him within touching distance of a first victory over Federer in seven attempts.
Although the fourth set already looked beyond the Frenchman, there was no certainty that Federer - who has suffered his own knee issues over the past 16 months - would have maintained the momentum.
"It is awful, it shows that one shot can change the outcome of a match, a season, a career. I wish him all the best," said Federer.
"I hope he recovers quickly and we see him back on the courts. He could have won the match, he was the better player, I got lucky."
The Swiss 20-time Grand Slam champion will play France's Richard Gasquet or Japan's Yuichi Sugita in the second round.
In the match that followed on Centre Court, Serena Williams was forced to retire in the first set against Aliaksandra Sasnovich after slipping in the fifth game.
Federer still far from his best
There had been doubts over Federer's shape coming into his favourite Grand Slam, having suffered a chastening defeat at Halle earlier this month which left him uncharacteristically despondent afterwards.
During his pre-tournament media conference the Swiss was much more upbeat, saying he had learned from that experience and was "ready" and "pumped up" to make amends at Wimbledon.
Being drawn against left-handed Mannarino, against whom he had not dropped a set in two previous SW19 matches, appeared to give him a decent opportunity to do that.
But it turned into a slog for Federer before he was given a huge slice of luck, as a result of Mannarino's misfortune.
"I didn't want to win like this, but that's how it goes sometimes. You don't get many walkovers in a career and you try not to let it happen to yourself," said Federer.
"Obviously, I'm happy to get another opportunity to play another match here.
"I worked hard and in the end I enjoyed myself. It was great fun until the end."
While Federer was far from his best at the start, he raised his level at the crucial time and broke serve with a vintage backhand winner to clinch the opening set.
Then he became ponderous, with his shot-making and decision-making, perhaps as a result of some uncertain movement on the grass.
The last time he set foot on the hallowed Centre Court surface was for the classic 2019 final, which he ended up losing to Novak Djokovic, and had played only two grass-court matches at Halle since.
Mannarino began playing at a high level and, with Federer's serve and forehand misfiring, took advantage to lead two sets to one.
The biggest shock of the tournament so far was on the cards and Federer was facing his first opening-round exit at Wimbledon since 2002.
Backed by the majority of the 7,500 crowd, the tension was lifted by a fast start in the fourth and the match looked set to be decided by a competitive final set before Mannarino's unfortunate slip.