Signaling his recent tailspin may be over, Federer avenged a defeat four years ago at the Olympics by beating Tomas Berdych of the Czech Republic 6-3, 7-6 (4) Wednesday to reach the quarterfinals.
It was Federer's biggest victory since he lost to Rafael Nadal in an epic Wimbledon final last month.
Federer wept after losing to Berdych in the second round at the Athens Games in 2004. This time he was shouting "Yes!" and punching the air after he smacked a service winner on match point to finish off Berdych.
"Of course you have memories of such a big tournament and losing," Federer said. "He's a good player. So I'm very happy with this win, because I think this was the first true test in this tournament."
Nadal also advanced, digging out of a hole in a pivotal service game and beating Igor Andreev of Russia, 6-4, 6-2. Venus and Serena Williams won to remain on course for a sibling showdown in the women's final Saturday.
Nadal and Federer could meet for the gold medal Sunday. Regardless of the tournament outcome, Nadal is assured of climbing to No. 1 in the rankings next week, ending Federer's 4 1/2-year reign.
Federer will next face No. 8 James Blake, who advanced by beating No. 10 Gilles Simon of France 6-4, 6-2. Blake, the lone U.S. male to survive the first round of singles, is 0-8 against Federer and has won only one of their 22 sets.
"If he's too good for me, he's too good for me," Blake said. "Every time at the beginning of each match, I've felt like I could come out on top."
Blake is part of an American team that has gone 11-0 the past two days. The Bryan brothers won in doubles, as did Lindsay Davenport and Liezel Huber.
No. 3 Novak Djokovic, who could face Nadal in the semifinals, beat No. 13 Mikhail Youzhny of Russia 7-6 (3), 6-3.
No. 4 Serena Williams busted a racket in frustration over a slow start, then rallied to beat 18-year-old Alize Cornet of France 3-6, 6-3, 6-4.
Williams' outburst came as she fell behind 5-1 in the first set.
"I've been really working on my temper," she said. "But I was just making so many errors, and I wasn't practicing like that at all. It came to a point, I think I hit a backhand in the net, and I had just had enough."
Williams gradually tamed her erratic groundstrokes, and after managing a service break in the opening game of the final set, she held in five consecutive games for the victory.
Venus Williams, playing her first tournament since winning Wimbledon for the fifth time, also reached the final eight by defeating No. 12 Victoria Azarenka of Belarus 6-3, 6-2. Venus, seeded seventh, is seeking to add to her Olympic medal collection after winning the doubles with her sister and the singles at Sydney in 2000.
"It's only every four years, so now is the time to really play well," she said.
Jelena Jankovic of Serbia, who this week achieved the No. 1 ranking for the first time, beat No. 16 Dominika Cibulkova of Slovakia 7-5, 6-1. Jankovic's next opponent will be No. 6 Dinara Safina of Russia, riding a 13-match winning streak after beating Zheng Jie of China 6-4, 6-3.
In doubles, top-seeded Mike and Bob Bryan of the United States beat Julian Knowle and Jurgen Melzer of Austria 7-6 (2), 6-4. Davenport and Huber eliminated Victoria Azarenka and Tatiana Poutchek of Belarus 6-4, 4-6, 6-3.
"It's looking great for the Americans the past couple of days," Mike Bryan said. "It would be great if we could finish up strong here and walk away with a few medals."
Federer and Stanislas Wawrinka won their doubles match, which finished at 11 p.m. Federer then complained about a schedule that will require him to play 11 matches in seven days if he keeps winning.
"I find it a little bit ridiculous," Federer said. "I don't understand why we don't play such a big tournament over 10 days maybe. I think this is asking just a little bit too much."
Nadal and doubles partner Tommy Robredo lost to Lleyton Hewitt and Chris Guccione of Australian 6-2, 7-6 (5).
In the day's showcase match, Federer broke Berdych for a 4-2 lead in the first set and let out a guttural "hmmmpf," sounding as though he was lifting a heavy load off his shoulders. Which is exactly what he's trying to do in Beijing.
The stylish Swiss seeks his first medal after getting shut out at Sydney and Athens. He's also trying to end a slump that has left him without a major title this year, stalling his career total at 12, two shy of Pete Sampras' record.
Federer hit three aces in the final game of the first set, but his serve briefly went haywire two games later. He had three double-faults -- more than he often hits in an entire match -- and fell behind 3-0.
But those were his only double-faults, and he otherwise served well, breaking back in the fifth game and holding the rest of the way. In the tiebreaker he rallied from 3-1 down while hitting three service winners and his 11th ace.
Since losing to Berdych in Athens, Federer has beaten the Czech seven consecutive times while losing only one set.
"I got it out of my system, I guess, the first time I beat him," Federer said. "It was nice to get him back, I guess, on the Olympic level."