Roger Federer joined Rafael Nadal in the Shanghai Masters third round but needed to dig deep to see off Diego Schwartzman in straight sets.

In his first ATP Tour appearance since the US Open, Federer was at his elegant best, showing no signs of the back problems that had hampered him earlier in the year.

A 696th hard-court victory was secured after 93 minutes, the Australian Open and Wimbledon champion setting up a meeting with Alexandr Dolgopolov in a 7-6 (7-4) 6-4 win.

Schwartzman gave as good as he got early on, but cracks in his serve began to appear midway through the set.

After wasting three break chances, Federer eventually converted one to move ahead, only for Schwartzman to hit straight back – the Swiss uncharacteristically firing a forehand long.

It was a rare error from the second seed, although his opponent's play was erratic with too many mistakes coming from the Argentine's forehand.

A tie-break ensued and it was Federer who prevailed, Schwartzman's ire growing by the point as calls continued to go against him.

If he was angry then, his mood will not have improved as Federer broke to love at the start of the second.

Schwartzman would not lie down, though, and he regularly exchanged blows from the baseline with his 19-time grand slam-winning rival.

The consistency of Federer proved crucial as he continually found the lines with pinpoint groundstrokes, while he was supremely clinical at the net as Schwartzman tried to power shots past.

With victory in sight, Federer unleashed two perfect aces to seal his progression, Schwartzman only able to waft his racket at them as his brave show came to an end.