The Swiss star was battling to stay alive against Adrian Mannarino, but a bad fall would see the Frenchman retire before the start of the final set. Federer will face Richard Gasquet next.
The newly crowned major champion kicked off her Wimbledon campaign with a solid 6-3, 6-2 score over Clara Tauson.
The 17-year-old is off to a winning start. She defeated Francesca Jones, 7-5, 6-4, to set up a second-round meeting with Elina Vesnina.
The 2018 champion hit the ground running and posted a 6-4, 6-3 score over Nina Stojanović to move into the second round.
The Russian was dealt a tough opening round opponent in Jan-Lennard Struff, but managed to grab a 6-4, 6-1, 4-6, 7-6 (3) win.