Defending champion Federer defeated fellow Swiss Stanislas Wawrinka 6-3, 6-7 (4/7), 7-5, laboring two hours and 20 minutes to subdue his old friend.
Nadal, playing his fourth tournament since returning from a seven-month injury absence, outlasted the in-form Latvian Ernests Gulbis 4-6, 6-4, 7-5.
The other two of the “big four” of men’s tennis also reached the quarter-finals of combined ATP Masters and WTA event.
World No. 1 Novak Djokovic defeated American Sam Querrey 6-0, 7-6 (8/6) in a match that started after midnight and finished around 2am on Thursday.
World No. 3 Andy Murray beat unseeded Argentinian Carlos Berlocq 7-6 (7/4), 6-4.
Djokovic’s late night was the result of some long matches Wednesday on stadium court.
Federer had a golden opportunity to make his day much shorter, but serving for the match at 5-4 in the second set he was broken to love.
Unable to convert two break points in the following game he surrendered the set on a tiebreaker when he double-faulted on set point.
Wawrinka then gained the upper hand with a break in the third set, but Federer, winner of 17 Grand Slam titles, broke back and earned the decisive break in the final game.
“I think I was a little little lucky to come through it in the end,” said Federer, who continued to say a sore back would not hinder his pursuit of a first title of 2013.
“Overall I’m very pleased that I was able to play today and play at a high level,” Federer said.
Nadal is playing his first hard court tournament since left-knee tendinitis forced him out of the Miami Masters last March.
Damage in the same knee later sidelined him for seven months — from a second-round defeat at Wimbledon until a comeback swing of three clay-court tournaments in Latin America in February that yielded two titles and a runner-up finish.
Nadal had admitted he did not know how his knee would hold up on hard courts, and in qualifier Gulbis he came up against a red-hot player who had won the Delray Beach title as a qualifier the week before Indian Wells and toppled two seeds en route to his meeting with the Spaniard.
“Always against Ernests it’s a very difficult match,” Nadal said. “He’s a very, very aggressive player with a big serve.”
Nadal saved the only break point he faced in the third set, and converted his only opportunity to break in the 11th game.
When he finally blasted a forehand winner on his third match point, Nadal gave a little leap of joy
The last time he played Federer was in the semi-finals at Indian Wells last year when he lost 6-3, 6-4.
A packed schedule on stadium court saw Nadal’s match, the last of the day session, finish at at 9:47pm.
Then came Maria Sharapova’s 7-6 (8/6), 6-2 victory over Italy’s Sara Errani in a rematch of the French Open final won by the Russian superstar last year.
Sharapova booked a semi-final clash with Maria Kirilenko, who upset fifth-seeded Czech Petra Kvitova 4-6, 6-4, 6-3 in the only other women’s match of the day.
Djokovic took the court at 12:23 against Querrey, but there was no upset for the American this time as the world’s top player set aside the frustration of his long wait to win in one hour and 27 minutes.
Djokovic, a two-time winner here in 2008 and 2011, next faces France’s Jo-Wilfried Tsonga, a 4-6, 7-5, 6-4 winner over Canadian Milos Raonic.
Murray will take on another Argentinian, seventh-seeded Juan Martin del Potro. Del Potro cruised past German veteran Tommy Haas 6-1, 6-2.
Sixth-seeded Czech Tomas Berdych also advanced, beating France’s Richard Gasquet 6-1, 7-5 to advance to a quarter-final meeting with South African Kevin Anderson — a 6-3, 1-6, 6-4 winner over France’s Gilles Simon.