Roger Federer gained revenge for his US Open defeat to Juan Martin del Potro by coming from behind to set up a mouth-watering Shanghai Masters final against Rafael Nadal.

Del Potro dumped the 19-time grand slam champion out in New York at the quarter-final stage last month and threatened a repeat before going down 3-6 6-3 6-3 in a gripping semi-final on Saturday.

There were concerns that Del Potro would not be fit to face Federer after damaging his left wrist during a last-eight meeting with Viktor Troicki on Friday, but the 16th seed showed no signs of being hampered in a typically powerful display.

Del Potro had more of an issue with the crowd, clearly unimpressed with the etiquette from some spectators and taking up grievances with the chair umpire as Federer came from behind to set up yet another showdown with Nadal – who beat Marin Cilic in the first semi-final. 

Del Potro's aggressive approach combined with tenacious defence paid off when he took a 4-2 lead in the first set, 2014 Shanghai champion Federer overcooking a backhand under pressure to go a break down.

The pumped-up 2009 US Open champion was relishing the battle, winning a pulsating rally when Federer ballooned a forehand wide and grasping the opportunity to serve out the opening set with an ace.

Federer unleashed sublime forehand and backhand winners and his persistence paid off when he took his fifth chance to break in a lengthy sixth game of the second set.

A disgruntled Del Potro was chuntering at the chair umpire and despite keeping his composure to save two break points on serve, he could not prevent Federer from serving out the set to love.

Federer, with the crowd firmly in his corner, went a break up at 2-1 in the decider after some brilliant retrieval work prior to his opponent netting a forehand.

Del Potro was unable to claw his way back, Federer not allowing his opponent a single break point opportunity in the final set as he sealed a seventh semi-final win out of seven this year.