MADRID -- Facing match point and on a second serve, Roger Federer decided it was time for a "panic move."
So he went into all-out attacking mode, charging to the net to try to avoid a disappointing end to his first clay-court tournament since 2016.
A lucky volley, followed by a smash winner, kept Federer in the match. An aggressive forehand two points later allowed him to save a second match point, and he went on to beat Gael Monfils 6-0, 4-6, 7-6 (3) in the third round of the Madrid Open on Thursday.
"I felt my chances were bigger at the net than from the baseline, so it was a desperation, panic move," Federer said. "I was very nervous, so I just figured, `come to the net, take a chance,' and it worked out."
In only his second match on clay in three years, Federer rallied from three games down late in the third set and then dominated the deciding tiebreaker to outlast Monfils and reach the quarterfinals in a match of more than two hours on center court.
It was the 1,200th career win for Federer, allowing him to join Jimmy Connors as the only male players to have reached the milestone in the Open Era.
"I'm not sure if I've lost a match before after winning the first set 6-0. The statistics show that usually you are in good shape. But with Gael you really never know," Federer said. "He really got into a great groove after that, he had great intensity. At the end I played a great tiebreaker so I'm very relieved and I'm very happy right now."
The fourth-seeded Federer had eased past Richard Gasquet in his first match in Madrid and looked set for another comfortable win after routing Monfils in less than 20 minutes in the opening set. But the Swiss lost five straight games to fall behind the 18th-ranked Frenchman who was seeking his second title of the season.
Federer, who looked frustrated at times, recovered after being down 0-3 and 1-4 in the third set. He saved the two match points in a long game when trailing 5-6. The 20-time Grand Slam champion was back in control in the tiebreaker, winning six of the first seven points.
Monfils, who won only nine points in the first set, was seeking his 19th win this season. He won the Rotterdam title in February.
Federer will next face fifth-seeded Dominic Thiem, who defeated Fabio Fognini 6-4, 7-5. The fifth-ranked Austrian is coming off titles in Barcelona and Indian Wells. He was runner-up in Madrid the last two years.
Federer, who earned his 20th win of the season, skipped the clay swing the last two years to remain fit for the rest of the season. The Madrid Open is his first clay tournament as he prepares to return to the French Open after a three-year absence. He has already won two hard-court titles this season, in Dubai and Miami, and is seeking his third Madrid trophy, and first since 2012.
"You do have a little bit more of a confidence coming into a match knowing that you've never lost to your opponent," Djokovic said. "But he was playing well here."
Djokovic is seeking his second title of the season, and third in Madrid. He began the year by winning the Australian Open.