Novak Djokovic and Victoria Azarenka, the top-ranked man and woman, had much easier paths to victory.
Federer, the 2009 champion at Roland Garros, was pushed to four sets Friday for the second straight match, this time beating Nicolas Mahut of France 6-3, 4-6, 6-2, 7-5 in the third round.
"I think for bigger guys it's about, if you're able to move them around enough and they have to defend time and time again, this is maybe where you can expose some of their weaknesses potentially," Federer said. "I thought he did well. (I) struggled a little bit, but overall obviously I'm happy I came through."
With the win, Federer improved his record number of Grand Slam match wins to 235. The 16-time Grand Slam champion is trying to become the first man over 30 years old to win a major title since Andre Agassi in 2003 at the Australian Open.
For Mahut, it was the first time he has ever won a set against Federer in four matches.
"I was believing in it. I was maybe a bit nervous going into that centre court, but this went well," Mahut said. "But I'm disappointed, because you always want to do better. Disappointed I didn't win that fourth set."
Djokovic also advanced to the fourth round, extending his Grand Slam win streak to 24 matches by beating Nicolas Devilder of France 6-1, 6-2, 6-2 in a match that ended just as the sun was setting.
"Last 15 minutes was very hard," Djokovic said. "It was very important for me to finish the match today. I wouldn't like to come back tomorrow and play a few games."
No. 5 Jo-Wilfried Tsonga of France, No. 7 Tomas Berdych of the Czech Republic and No. 9 Juan Martin del Potro also won, while No. 11 Gilles Simon lost.
Azarenka reached the fourth round in the woman's draw, while Maria Sharapova advanced to the third round. But the big surprises came early in the day when third-seeded Agnieszka Radwanska and 2008 French Open champion Ana Ivanovic were eliminated.
Two days after beating seven-time Grand Slam champion Venus Williams, Radwanska was routed by 2009 French Open champion Svetlana Kuznetsova 6-1, 6-2.
On Court Philippe Chatrier, the 23-year-old Pole didn't look anything like the player who overwhelmed Williams in straight sets on Wednesday.
"She was just playing very aggressive on both sides," Radwanska said of Kuznetsova. "She just had (an) answer for everything I was trying to do."
Radwanska has been having a stellar year on tour, winning three titles and moving up to a career-high No. 3 ranking last month. But she is the only player in the top 10 who has never reached a Grand Slam semifinal.
"It's always disappointing when losing in the first week of a Grand Slam, that's for sure," Radwanska said. "Today I didn't play bad, she was just playing unbelievable."
Against Kuznetsova, however, Radwanska has struggled. She is now 3-10 against the Russian, including her only two losses in tournament finals.
Before Friday's match, Radwanska had been 38-7 in 2012, with six of those losses coming against top-ranked Victoria Azarenka.
Kuznetsova, who also won the U.S. Open in 2004, has struggled since winning the title at Roland Garros three years ago, only reaching one Grand Slam quarterfinal.
"I try to play more forehands. I try to dictate. I play more speed," Kuznetsova said of her play Friday. "This is the game I was playing when I won U.S. Open and I won the French Open."
In the second round, Sharapova advanced with another straight-forward, straight-set victory.
Three days after scoring a "double bagel" in the first round, the second-seeded Sharapova defeated Ayumi Morita of Japan 6-1, 6-1.
"I really wanted to try to get her on the move. I thought I played well, aggressive, moved in when I had to," Sharapova said. "With every round I'm going to be playing tougher opponents, and that's when you really want to kind of step it up and raise your level. That's what I'll try to do in the next round."
Sharapova has won three major titles in her career, but she still needs to win at Roland Garros to complete a career Grand Slam.
Last year, she lost in the semifinals at the French Open.
Also in the third round, the 13th-seeded Ivanovic lost to Sara Errani of Italy 1-6, 7-5, 6-3.
The former top-ranked player committed 37 of her 40 unforced errors in the final two sets. Errani had only 18.
"In the third set I was creating a lot of opportunities and missing a lot of easy, easy finishing balls," Ivanovic said. "That's something that I'm not really happy about."
For Errani, it was only the second time in 39 matches that she has beaten a player ranked in the top 15.
No. 6 Sam Stosur, the 2010 runner-up, advanced as well.
American teen Sloane Stephens also advanced to the fourth round, beating Mathilde Johansson of France 6-3, 6-2. Of the eight teenagers in this year's draw, the 19-year-old Stephens was the only one to even reach the third round.
"I'm excited because now I'm going to have more Twitter followers," Stephens said.Suggest a correction