Roger Federer conceded he had more than his fair share of good fortune in his Shanghai Masters win over David Goffin.

The Swiss maestro battled to a 7-6 (9-7) 6-4 triumph on Thursday to reach the last eight in China.

Federer saved five set points in the opener and sealed the second set after a solitary break of Goffin's serve.

"It was tough," said the 20-time grand slam champion. "He served for the set at 6-5. We both had chances but he probably had a few more I must admit.

"I had to play some very accurate shots and it went very close to the lines. They could easily have gone another way, I know that.

"I was a bit fortunate to win that first set but I played okay and I fought extremely hard.

"Sometimes it falls your way. I have had a good season and served well at the end.

"The first set was certainly crucial to put me in the lead."

The world number three will face Alexander Zverev in the quarter-finals.