Roger Federer had to dig deep before progressing through to the semi-final of the Madrid Open at the expense of Latvian Ernests Gulbis.
The 21-year-old had beaten world number one and reigning champion Federer in the Rome Masters last month and he threatened to repeat the feat tonight after taking the first set and breaking the Swiss ace straight away in the second.
However, Federer battled back in style and, despite some gutsy tennis from world number 34 Gulbis, claimed the second set 6-1.
Gulbis refused to be bowed though, and he earned a break point on Federer's first service game for a chance to take a 2-0 lead in the decisive third set.
Federer wiped out that opportunity with an ace however, and after holding his serve the top seed would go onto break Gulbis in the very next game before taking the match 3-6 6-1 6-4 in just under two hours.
Federer was delighted with the win, especially having lost to the same opponent recently.
"In the end I thought it was a great performance," he said.
"I think that's one of the toughest things in tennis, when you lose to a player and then you have to play him again in the next couple of weeks. It's tough, so that's why I'm particularly happy to come up with a proper gameplan today.
"And even though I got off to a slow start, I managed to come through."
Federer's semi-final opponent is David Ferrer - one of three Spaniards in the last four - after the ninth seed defeated Andy Murray in a gruelling encounter.
Ferrer beat the world number four 7-5 6-3 in a late-finishing match that lasted two hours and 11 minutes.
Whereas Federer found himself in a real battle to see off his opponent, claycourt king Rafael Nadal swept aside Frenchman Gael Monfils with relative ease in his quarter-final.
Spaniard Nadal won 6-1 6-3 to improve an astonishing record which has now seen him claim 166 wins in 172 matches on clay since 2005.
Nadal said: "Yesterday I improved and today I improved even more. In the first set I played at a very high level, then in the second it was more difficult because Gael tried to play shorter points and it was a bit trickier.
"But the level was good and I'm happy about it."
Nadal will now meet countryman Nicolas Almagro for a place in the final.
The unseeded Almagro, who beat fourth seed Robin Soderling in the second round, has still to drop a set in the competition after defeating Austrian Jurgen Melzer 6-3 6-1.
This is the first semi-final appearance in 12 events this year for 24-year-old Almagro, the world number 35.