Roger Federer saved two match points before claiming a hard-fought victory over Gael Monfils to reach the Madrid Open quarter-finals.
The Swiss fourth seed came from a break down in the deciding set to beat the Frenchman 6-0 4-6 7-6 (7-3).
Federer will face fifth seed Dominic Thiem - who he lost the Indian Wells final to in March - in the semi-finals.
"Instead of seeing a things bit more cloudy and rainy, you see it more on the sunny side," Federer said.
"You don't win matches every day saving match points and it makes you feel good, but it is more relief I feel right now."
The victory was Federer's 1,200th career win and secured his place in a first clay-court quarter-final since the French Open in 2015.
Earlier, world number one Novak Djokovic breezed past France's Jeremy Chardy 6-1 7-6 (7-2).
Rafael Nadal continued his pursuit of a sixth title by beating American Frances Tiafoe 6-3 6-4.
World number three Federer needed just 19 minutes to take the first set over Monfils, dropping just four points on his serve.
However, world number 18 Monfils rallied in the second set, taking advantage as Federer's first serve faded to force a decider.
Monfils raced to a 4-1 lead in the third set before Federer could force the match back on serve.
The Frenchman brought up two match points on Federer's serve but the 20-time Grand Slam champion saved them both with a serve and volley.
Federer was the stronger of the two in the tie-break, with Monfils saving two match points before a forehand error secured victory for the Swiss.
The Swiss said of his tactics on match point: "I felt not so confident to win the point from the baseline, so I said panic mode is switched on and we are coming in.
"You go to the net as quick as possible so you are as close as possible and I framed the first volley, which ended up being perfect."
He will play Barcelona Open champion Thiem on Friday after the Austrian's 6-4 7-5 win over Italy's Fabio Fognini.
Djokovic cruises into quarters
Despite being pushed as the match progressed, Djokovic has yet to drop a set against the world number 47 Chardy, having won all 13 of their meetings.
The 15-time Grand Slam champion moved a double break up in the first set when Chardy double-faulted for 4-0, then fought off a triple break point in the next game before going on to seal the opener in 31 minutes.
Chardy stretched Djokovic more in the second set, as neither player managed to muster a break point until the Frenchman - who had lost their previous 29 successive sets - claimed a set point at 5-4.
But he batted a backhand long as Djokovic, who shook his head after receiving whistles from the Caja Magica crowd as he prepared to serve, thumped down an ace to seal the hold.
That enabled Djokovic to take early control of the tie-break, clinching victory with a forehand winner on his first match point.
Cilic, Wawrinka, Tsitsipas and Zverev also advance
The top seed will face Marin Cilic next after the Croat reached his first quarter-final of the season.
Former US Open champion Cilic recovered to win 11 of the final 13 games to beat Serb Laslo Djere 4-6 6-3 6-2.
Switzerland's Stan Wawrinka also reached the quarter-finals, where he will meet Nadal, after beating Japan's Kei Nishikori 6-3 7-6 (7-3).
Germany's Alexander Zverev will face Stefanos Tsitsipas in the quarter-finals. Zverev beat Poland's Hubert Hurkacz while 3-6 6-4 6-4 while Tsitsipas beat Spain's Fernando Verdasco 6-3 6-4.
Tsitsipas was back on court a few hours later in the men's doubles, where he and partner Wesley Koolhof beat Britain's Jaime Murray and Brazil's Bruno Soares 6-2 7-6 (7-4) to reach the semi-finals.