"It was still a good match, I thought, for me to come through," said Federer, who is playing his tournament since the U.S. Open and served three straight double faults when broken in the second set. "It was due to my ups and downs that he got a chance."
Murray's injury left the third-seeded Swiss a clearer path to a possible final against top-ranked Novak Djokovic for a third straight year.
"I never saw (Murray) as a potential opponent anyway because I'm too focused on what I have to do," Federer said. "I am sure it is somewhat disappointing for the tournament director after going through all the headaches with the wild cards."
The second-seeded Murray of Scotland, who requested a late entry last week, pulled out of his match just before playing Robin Haase of the Netherlands because of a gluteal muscle strain. Murray had also been scheduled to pair up with brother Jamie in an evening doubles match.
Five of the current top-eight men were lined up in a tough main draw, but only Federer and Djokovic remain. Murray followed Mardy Fish of the United States in succumbing to injury, and Czech Tomas Berdych was ousted Tuesday by wild-card entry Kei Nishikori.
Sixth-seeded Janko Tipsarevic, like Fish on Tuesday, was hurt in his first-round match and retired.
Tipsarevic retired on serve while trailing Florian Mayer of Germany 5-1 in the first set. The Serb will have to reach at least the final in Paris next week if he's to qualify for the eight-man ATP World Tour Finals in London.
Murray's place in the singles draw was taken by lucky loser Marco Chiudinelli, a childhood friend of Federer, who lost 6-2, 7-6 (7) to Haase.
Marcos Baghdatis advanced to the quarterfinals by defeating 327th-ranked Swiss qualifier Michael Lammer 7-6 (2), 6-7 (2), 6-3. The Cypriot is a likely crowd pleasing matchup for Djokovic on Friday.