Andy Roddick advanced after Nikolay Davydenko withdrew with a leg injury. Roddick will next face Federer, who defeated James Blake 6-2, 6-4.
Murray stopped Tommy Robredo 7-5, 6-1, and Nadal moved up after Philipp Kohlschreiber also withdrew with a leg injury. Third-seeded Novak Djokovic defeated Andreas Seppi 6-4, 6-4. He will play wild-card Ivan Ljubicic, who rallied for a 3-6, 6-4, 6-3 win over 2008 finalist Gilles Simon.
The last time the Federer and Blake met at the Beijing Olympics, Blake ended the Swiss star's hopes of capturing his first Olympic singles medal.
"We haven't played since the Olympics and I was pleased with the way it went today, especially with him playing so well recently," Federer said.
The second-seeded Federer is looking forward to playing the sixth-seeded Roddick on a different surface.
"I've played Andy so many times, it's time we played each other on clay," Federer said.
Nadal will play Fernando Verdasco, who rallied from a break down in both sets to beat Juan Monaco 7-5, 6-2.
In the women's draw, top-ranked Dinara Safina overcame a mid-match dip, defeating Lucie Safarova 6-0, 4-6, 6-3 to advance to the quarterfinals.
Murray failed to convert seven break points before finally getting the decisive break to go up 6-5, and held serve to take the first set.
Murray, who turns 22 on Friday, began hitting long, accurate baseline shots and well-timed passes to dominate in the second.
"I noticed that at this altitude the ball tends to fly faster, and because the court is sprayed with water regularly, the balls also tend to pick up weight," Murray said. "I strung my rackets more tightly to compensate and was happy to be able to control the ball in the wind."
In other women's matches, Agnes Szavay rallied to beat Victoria Azarenka 4-6, 6-2, 6-2, and will face Amelie Mauresmo in the quarterfinals.
Alona Bondarenko defeated Anna Chakvetadze 6-0, 2-6, 6-3, and Caroline Wozniacki beat Alisa Kleybanova 6-2, 6-2. Kleybanova defeated third-ranked Venus Williams on Tuesday.