Roger Federer started his Shanghai Masters campaign by exacting revenge on Albert Ramos Vinolas to progress to the third round.

Federer, whose only previous matches since his US Open campaign ended in a thrilling five-set defeat to Grigor Dimitrov were at the Laver Cup, saw off an opponent he lost to at the same stage in 2015 in relatively straightforward fashion.

The 20-time grand slam champion, who was hindered by back problems in his loss to Dimitrov, needed only an hour and 24 minutes to see off Ramos Vinolas 6-2 7-6 (7-5).

It was far from vintage Federer, as he committed 31 unforced errors. However, Ramos Vinolas, who knocked out Marin Cilic in the opening round, never looked to have the firepower to pull off another shock as Federer set up a clash with either David Goffin or Mikhail Kukushkin.

Federer trailed 4-1 in the second-set tie-break, but won six of the next seven points to secure his progression as he seeks a third title in Shanghai.

"I got out the blocks quick, played a good match," the 38-year-old said afterwards. "Ramos had his chances in that tie-break up 4-1, that was a nice comeback there."

The likelihood of Federer, who sent down 32 winners, needing a comeback at any stage did not seem high when he breezed through the first set.

He dropped only two points on serve and was clinical in taking his opportunities when returning, breaking Ramos Vinolas three times.

The Spaniard proved more obdurate in the second, however, with neither player having an opportunity to break serve.

A repeat of Ramos Vinolas' success of four years ago looked a possibility when he forged ahead in the tie-break, but Federer was not to be denied and moved a step closer to a 29th Masters 1000 title.