Federer, the champion in Paris in 2009, overcame battling French world number 89 Nicolas Mahut 6-3, 4-6, 6-2, 7-5, being pushed to four sets for the second match in succession.
Goffin is the first lucky loser from qualifying to make the last 16 of a major since compatriot Dick Norman at Wimbledon in 1995 and the first at Roland Garros since 1978.
The 21-year-old achieved the feat by beating Poland's Lukasz Kubot 7-6 (7/4), 7-5, 6-1, having originally lost in the final qualifying round last week.
He was then handed a lifeline when French star Gael Monfils pulled out on the eve of the event.
Jo-Wilfried Tsonga did his part to keep alive home hopes of a first men's champion since 1983 when he swept past colourful Italian Fabio Fognini to reach the last 16.
Fifth seed Tsonga won 7-5, 6-4, 6-4 against the 45th-ranked Fognini and will face Stanislas Wawrinka, the 18th-seeded Swiss, who defeated French 11th seed Gilles Simon 7-5, 6-7 (5/7), 6-7 (3/7), 6-3, 6-2.
It was Tsonga's second win in two meetings with Fognini, who reached the quarter-finals last year only for a thigh injury to force him to withdraw and hand Novak Djokovic a walkover into the semi-finals.
"I have had some difficult moments here, now I am happy to be having some good ones," said Tsonga, who has now matched his best performances of fourth round runs in 2010 and 2011.
Andreas Seppi kept Italian interest alive by reaching the last 16 of a Grand Slam at the 29th time of asking.
The 22nd seed stunned Spain's 14th seed Fernando Verdasco 7-5, 3-6, 6-3, 4-6, 6-2 and could face Djokovic for a place in the quarter-finals if the world number one and top seed sees off France's world 286 Nicolas Devilder.
Seppi, who won the claycourt title in Belgrade in the run-up to Roland Garros, had lost all six of his previous meetings with Verdasco going into Friday's tie.
Seventh-seeded Czech Tomas Berdych ended Kevin Anderson's hopes of becoming the first South African man to reach the last 16 of a Grand Slam for nine years in a third round slugfest.
The 31st seed from Johannesburg was attempting to match comptariot Wayne Ferreira who made the fourth round at the Australian Open in 2003.
But after taking a two sets to one lead, he ran out of steam in the final set, when he needed treatment on his left thigh at every changeover, and lost 6-4, 3-6, 6-7 (4/7), 6-4 6-4, eight minutes short of four hours.
Berdych, a semi-finalist in Paris in 2010, will next take on ninth seed Juan Martin Del Potro of Argentina, the 2009 US Open champion, who put out Marin Cilic, the Croatian 21st seed 6-3, 7-6 (9/7), 6-1.
"When I played him (Anderson) in the first round in Madrid, he was the toughest player I faced until the semi-finals," said Berdych, who went on to be runner-up to Roger Federer in the Spanish capital.
"So I was expecting a tough one today. He is a player who is coming up and playing really well."
World number 98 Malek Jaziri wasted a great opportunity to become the first Tunisian man into a Grand Slam third round when he squandered three match points against Spanish 20th seed Marcel Granollers.
In a match held over from Tuesday, Granollers edged past Jaziri 7-6 (7/1), 3-6, 6-1, 3-6, 7-5 and will face France's Paul-Henri Mathieu for a place in the last 16.
(For more sports news and updates, follow Ahram Online Sports on Twitter: @AO Sports)
Short link: