Novak Djokovic then stretched his unbeaten run for the year to 34 matches after winning eight of the last nine games against Swiss Stanislas Wawrinka to triumph 6-4, 6-1.
Third-seed Federer took the first set 6-4 against France's Richard Gasquet but, in a match of clean-hitting strokes, lost the next two sets against the 16th seed on tiebreaks (7-2, 7-4).
World number four Andy Murray, Robin Soderling, Czech seventh seed Tomas Berdych, Croat Marin Cilic and German Florian Mayer also made it through to the last eight.
"I should never have lost this match," said world number three Federer, knocked out by Ernests Gulbis in the second round in Rome last year.
"He knows how close he came to losing. I had multiple chances but I couldn't make the difference."
The Swiss, who had won the last eight matches between the two, broke serve in the very first game but Gasquet responded with 10 straight points to draw level at 2-2.
The long thrilling rallies had both players covering every bit of the court but it was Federer who broke again in the seventh game with two sweet forehands to take the set.
Gasquet, whose one victory against Federer had come on clay at Monte Carlo in 2005, fought back by trouncing the tired-looking Swiss in the second set tieback with a backhand winner before a flourishing crosscourt forehand.
With games going with serve in the deciding set, Gasquet again showed a steelier side, forcing Federer into two top-spin backhand errors in another confident tiebreak to take the scalp.
World number one Nadal reached the quarter-finals with a 6-4, 6-2 defeat of fellow left-hander and Spaniard Feliciano Lopez.
"I had a fever last night and only decided at the last minute to go on court," said Nadal, champion in Rome for five of the last six years.
On Wednesday he came within two games of a shock defeat by Italian qualifier Paolo Lorenzi, adding to concerns for the Mallorcan whose 37-match winning streak on clay was ended by Djokovic in the final of the Madrid Open.
Djokovic can knock Nadal from the top of the rankings if he wins the title and the Spaniard falls before the semi-finals.
Nadal said he would take no chances with his health with the start of the French Open just over a week away, although he played down speculation he might not be fit to defend his title.
"Why wouldn't I be OK for Roland Garros?" he said.
"In 2009 I wasn't OK. My knee was destroyed. I'm worried about tomorrow, not in one week-and-a-half's time."
Despite his illness Nadal stamped his authority from the start against Lopez, winning the opening three games, but his early fire fizzled out as the unseeded Lopez hit back for 4-4.
Nadal held serve for a 5-4 lead and Lopez buckled in the 10th game, missing a volley, netting an attempted dropshot and then watching as Nadal unleashed a fierce backhand winner.
Nadal waited until the sixth game of the second set to launch a match-ending attack, firing another flashing backhand pass and then winning a 26-stroke rally with a savage forehand to break the Lopez serve and cruise to victory in the sunshine.
Starting late in Rome evening, Djokovic began strangely out of sorts against 14th seed Wawrinka, but up 5-4 and 30-30, the Serbian punched a decisive crosscourt winner after an exhausting rally before producing an elegant dropshot to snatch the set.
After that the second set was a procession with Djokovic, who has won his last six tournaments, dispatching two passing shots to take a 5-0 lead before winning the set with an ace.
Murray cruised into the last eight with a confident 6-2, 6-3 win over Italian number one Potito Starace, while Berdych, the man Nadal beat in last year's Wimbledon final, also reached the quarters with a 6-2, 6-7, 6-2 win over Jarkko Nieminen.
-ReutersTags: sport, tennis, italy First posted May 13, 2011 06:10:00