Roger Federer survived a soulless late-night scrap with German Dominik Koepfer to reach the fourth round of the French Open – then admitted he could pull out of the tournament with Wimbledon in mind.

Roland Garros’ new night session matches are being held behind closed doors this week because of a 9pm curfew in Paris, and Serena Williams, Novak Djokovic and Rafael Nadal have all taken their turn playing to an empty stadium.

But the sight of tennis’ biggest superstar, who attracts sell-out crowds wherever he goes, fighting for his life in the tournament in such circumstances was particularly jarring.

Had he lost, it could well have been the saddest of farewells to an event that has loved him arguably more than any other, and that looked a distinct possibility for nearly all of the three hours and 35 minutes they were on court.

Federer searched and searched for his game, finding it in patches only for the errors to creep in again, but he eventually secured a 7-6 (5) 6-7 (3) 7-6 (4) 7-5 victory and a place in the last 16 against Italy’s Matteo Berrettini.

Federer has always cited Wimbledon as his main goal of the season, and he said: “These are all stepping stones to something that is really important to me.

“We go through these matches, we analyse them highly and look on what’s next and will do the same tonight and tomorrow, because I need to decide if I keep on playing or not or is it not too much risk at this moment to keep on pushing or is this just a perfect way to just take a rest.

“Because I don’t have the week in between here and (the grass-court tournament in) Halle like normal, (we need) to see what’s best now if you count back from Wimbledon.

“It’s just a lot going on but, having a match like this, knowing I could have probably played a fifth set but not knowing how I will wake up tomorrow, is interesting, to say the least.”

German Koepfer, ranked 59, was looking to reach the fourth round at a slam for just the second time having already posted his best result at Roland Garros.

Federer ground out the first set and was twice an early break up in the second but Koepfer kept snapping at the 20-time grand slam champion’s heels, troubling him with the weight of his ball-striking and tenacious play.

It was Koepfer who took the set after an error-strewn tie-break from Federer, and the eighth seed was in a real hole down a break in the third set.

But he pulled it back to 4-4 and clinched the set on another tie-break – it was the first time in Federer’s long grand slam career that he had ever been involved in a match where the first three sets were decided by tie-breaks.

Roger Federer hits a forehand in front of an empty stadium
Roger Federer hits a forehand in front of an empty stadium (Thibault Camus/AP)

As the clock ticked past midnight, Federer moved a break ahead early in the fourth set only to give the advantage straight back despite Koepfer, who had earlier received a warning, being given a point penalty for spitting on a ball mark.

Koepfer’s resistance ran out when he was broken for 6-5, with Federer, who turns 40 in August, finally clinching a weary victory.

Federer’s two knee operations mean he has mostly missed pandemic tennis with all its restrictions, and he said: “To go out tonight, sure, it wasn’t easy.

“It was a lot of premiers for me: playing against Koepfer for first night session here in Paris, first time no fans in a long, long time, or ever in my career. That was definitely very unique in many ways, and I’m happy I found a way.

“Also especially emotionally, how do you handle losing that second set? How do you handle to keep pushing yourself on and try to feed off the energy of the team and thinking of all the people watching on TV?

“I was really picturing a lot of people on a Saturday night maybe checking in on the game and watching some tennis. So, in many ways, I was also playing for them and trying to let that inspire me.

“I clearly hadn’t practised for three hours 35. I pushed as much as I could, as we thought reasonable. But this today was I think a huge step forward for the team. I didn’t expect to be able to win three matches here.”