Federer and Nadal both needed three sets to beat Stanislas Wawrinka and Ernests Gulbis respectively to meet in the quarter finals of the competitipn.
World number two Federer meanwhile needed two hours and 20 minutes to prevail 6-3 6-7 (4/7) 7-5 in his all-Swiss encounter with Wawrinka.
Federer had won 12 of the pair's previous 13 meetings and looked set to extend that run with ease when he served for the match at 5-4 in the second set, but Wawrinka broke to love then took the tie-breaker.
Wawrinka also led by a break in the third but could not hold on for victory against his friend and Davis Cup team-mate.
"Today [Thursday] for sure I had some chances," said Wawrinka. "I had some opportunities, but I [could have] lost the match in two straight sets, too.
"I was close, but not enough, and that's why I need to still go practise and practise again."
It was a similar story in the match between fifth seed Nadal and rejuvenated Latvian Gulbis.
Gulbis, back up to 67 in the world and climbing, took the first set against the Spaniard and gave him plenty of problems in the second and third too, before Nadal eventually triumphed 4-6 6-4 7-5, with a single break in game 11 enough to seal the final set.
There were no such troubles for world number one Novak Djokovic, who beat American Sam Querrey 6-0 7-6 (8/6) and will next face eighth seed Jo-Wilfried Tsonga, a 4-6 7-5 6-4 winner over Milos Raonic.
Andy Murray defeated Carlos Berlocq in a battling 7-6 (7/4) 6-4 win to seal a meeting with Juan Martin Del Potro.
Murray was rattled not only by the quality of his opponent's play but also by the grunting coming from his opponent - he twice had to battle back from a break down in the first set against a fired-up Berlocq.
"It was tough," Murray told www.atptour.com. "He started well and he was playing very aggressive.
"He had a lot of chances in the first set. He obviously served for it.
"And then the second set was kind of the other way around. I had a lot of chances, but it was still tight. All the games were pretty close, a lot of long games and longish rallies."
After Berlocq broke in game three, Murray immediately forced a break-back point, but Berlocq saved it with a sweet backhand down the line and held for 3-1.
Berlocq was playing out of his skin and Murray had to be at his best to force two more break points in the next game, and he converted thanks to a rare backhand error from the Argentinian.
At that stage it looked like Murray might pull away, but it was not to be as Berlocq broke again for a 5-4 lead.
A double fault from the Argentinian gave Murray two break-back points, though, and he converted at the second attempt.
The set went to a tie-breaker and the key moment came when Berlocq pulled a forehand into the tramlines to give his opponent two set points, though Murray only needed one.
A backhand error from Berlocq gave Murray an immediate break at the start of the second set.
Berlocq broke back for 2-2, though, and a clearly frustrated Murray complained about the noise coming from his opponent after he passed up two opportunities to re-establish his advantage in the next game.
The break did come, though, as a neat lob gave him a 4-3 advantage and when Murray, thanks to an ace, saved a break point to hold, Berlocq was serving to stay in the match at 5-3.
He succeeded, but Murray made no mistake and completed a testing victory which put him through to a last-eight clash with Argentinian seventh seed Del Potro, a 6-1 6-2 winner over Tommy Haas.
The other quarter-final will be between Tomas Berdych and Kevin Anderson, who beat Richard Gasquet and Gilles Simon respectively.
In the women's quarter-finals, second seed Maria Sharapova was a straight-sets winner over sixth seed Sara Errani, going through 7-6 (8/6) 6-2.
In the semi-finals she will meet fellow Russian Maria Kirilenko, the 13th seed, who overcame Czech fifth seed Petra Kvitova 4-6 6-4 6-3.