Federer, the Swiss superstar who is looking for his first Olympic singles gold medal, outlasted American John Isner 6-4, 7-6 (7-5) and Williams continued to breeze through the field with a 6-0, 6-3 decision over former No. 1 Caroline Wozniacki of Denmark.
Isner put 73 percent of his powerful first serves in play and produced eight aces, but he made 22 unforced errors to just 12 for his world No. 1 ranked opponent.
Federer will meet Juan Del Potro in the semifinals after the Argentine fought off Gilles Simon of France 6-1, 4-6, 6-3.
The other semifinal will send Novak Djokovic of Serbia against Britain's Andy Murray, who lost to Federer in the finals of Wimbledon last month.
Djokovic, seeded second behind Federer at the Olympics, defeated Jo-Wilfried Tsonga of France 6-1, 7-5 while Murray ousted Nicolas Almagro of Spain 6-4, 6-1.
Williams will face the No. 1 seed Victoria Azarenka of Belarus in the semifinals. Azarenka was a 6-4, 7-5 winner over Angelique Kerber of Germany.
In the men's doubles quarterfinals, the top-seeded American pair of Mike and Bob Bryan prevailed over Johathan Erich and Andy Ram of Israel 7-6 (7-4), 7-6 (12-10).