Roger Federer produced a sensational comeback after saving four match points to defeat fellow-Swiss Stanislas Wawrinka in a pulsating encounter and set up a meeting with defending champion Novak Djokovic in the final of the ATP World Tour Finals in London.

The six-time former winner at the season-ending tour finals was four times on the brink before eventually prevailing 4-6 7-5 7-6 to deny Wawrinka a maiden final appearance at the O2 Arena.

Djokovic, going for his third title in a row in the English capital, had earlier fought off the challenge of debutant Kei Nishikori in three sets in the first semi-final to reach a fifth final in finale to the ATP season.

Sunday's final will see the two unbeaten players in the tournament collide for a 37th time and on a sixth occasion in 2014 in a fitting finale to the season but Wawrinka will be left to wonder how he will not feature after a harrowing loss to his Davis Cup teammate.

Ahead of that Davis Cup final against France next week, Switzerland's main two protagonists went head-to-head in search of a positive end to their 2014 season.

Wawrinka had beaten Federer just twice in 16 meetings between the two but did prevail in the Monte Carlo Masters final on clay earlier in the year but having played Marin Cilic less than 24 hours earlier had significantly less preparation time than his fellow-countryman.

But any jadedness Wawrinka was suffering was unnoticeable in the opening exchanges as the 29 year old inflicted on Federer his first break of the tournament to serve at 2-1 following a series of powerful ground-strokes.

It was a lead the Australian Open champion would soon build on as a stunning forehand opened up a double-break and allowed Wawrinka to serve for the first set, but a double-fault as nerves took a hold handed the initiative back to Federer.

The 17-time major champion held to further cut the deficit but despite a second double-fault Wawrinka kept his composure to crucially take the first set.

On serve at 3-2, Federer missed three opportunities to alter the momentum as Wawrinka protected his advantage with three desperately saved break points to wriggle away from danger.

The pressure was back on the No.3 seed when Federer held in double-quick time in the ninth game but Wawrinka responded once again despite cracks continuing to show in his serve.

However, with Wawrinka eying a second set tiebreak he finally relented as a netted overhead brought up three set points which Federer took at the first attempt to take the match into a decider.

If Federer thought his charge back into the contest was expected to run into the third set then Wawrinka had other ideas and the Swiss No.2 grabbed the most crucial of breaks to land the first blow of the deciding set.

With the end in sight, Wawrinka held a Federer comeback off by saving two break points while leading 4-3, the first as his opponent sent a cross-court forehand wide and then as he dabbed a drop volley out of reach.

That was far from the final opening for Federer though, who saved a match point with a breathtaking forehand down the line before bringing up a break-point of his own which was saved with a customary backhand winner.

Wawrinka netted a volley with the court at his mercy when handed a second chance to seal the match, before Federer saved a remarkable third match point with a crushing forehand winner.

And the turnaround was completed when when facing a second break point of the game, Wawrinka netted on the forehand side as the chance to clinch a place in the final slipped through his fingers.

Two stunning winners gave Wawrinka the immediate chance to bite back however but Federer survived as the match went into a never-jangling third set tiebreak.

Federer led 4-2 at the changeover but Wawrinka fought back and had a fourth chance to win the match but send a return long, but the 33 year old made no mistake when presented with the chance to claim victory with the calmest of volleys.