Roger Federer, as only he would dare to do, serve-volleyed on a second serve to save one of two match points and then went on to claim the 1,200th win of his career but there were moments here at the Madrid Open when the intangible magic of Gaël Monfils threatened to ruin his return to clay this week after an absence of nearly three years.

Federer losing a tennis match once had the bar-emptying resonance of “Bradman Out” on newspaper posters outside cricket grounds many decades ago and, while the days of preordained dominance might be dwindling for the Swiss, his fans still expect him to win every time he steps on a court, no matter what the surface. For the last half-hour of a thrilling last-16 encounter, they held their collective breath.

Victory looked to be slipping from his grasp when Monfils raced to 3-0 in the third set and Federer threw a rare strop, complaining about the late-afternoon shadow cast by the partly withdrawn roof. Monfils cared not a jot, stretching the lead to 4-1. But Federer was magnificent when it mattered.

Nevertheless, beating the unpredictable Frenchman 6-0, 4-6, 7-6 (3) in two hours, having won the first set in 18 minutes, raises some obvious questions. Is his focus what it was? Can his 37-year-old legs carry him through a fortnight of five-setters on the slower, muscle-draining clay of Roland Garros, which starts on 26 May? Even he will be unsure.

Federer will learn much about the state of his game when he faces a more conventional challenge in the quarter-finals on Friday against the world No 5, Dominic Thiem, 12 years his junior, who looked in excellent touch beating Fabio Fognini in two sets over 90 minutes.

Federer said courtside: “Gaël did a nice job of not being frustrated after losing the first set, as he did the day before [dropping the opener to Marton Fucsovics 6-1]. I had a tough run of losing five games in a row, but I hung in there after I saved match point serve-volleying on second serve. Gaël helped me out with a few double faults [seven]. I’m very, very pleased.” And relieved.

On Federer’s side of the draw, Novak Djokovic was barely inconvenienced dismissing Jérémy Chardy, 6-1, 7-6 (2) in an hour and 25 minutes. Chardy, who had not taken a set off Djokovic in their 12 previous matches over 10 years, had three chances to break in the first set and again in the pivotal 10th game of the second, but took none of them.

Djokovic has now lost only twice to Frenchmen in 68 matches since he helped Serbia to beat France in the 2010 Davis Cup final. That said, he wins nearly nine out of 10 matches against players from all nations. Next he plays Marin Cilic, whom he defeated three out of four times last year and against whom he has lost only twice in 19 meetings.

Cilic outlasted the determined Serb Laslo Djere, 4-6, 6-3, 6-2 – but the world No 11 and 2014 US Open champion was not happy having to play on the tournament’s second court, Arantxa Sánchez. “This court is really tough to play,” he said. “It’s one of the worst experiences I’ve had, I’m sorry to say, with the shade and the sun. To put the last 16 here in these conditions is not good. This was my third three-setter here. I hope I can rise to the task again.”