Roger Federer got his ATP Finals campaign back on track with a 7-6 (7-2) 6-3 win over Matteo Berrettini.

The six-time winner, beaten in his opening round-robin match by Dominic Thiem, needed a victory over eighth-ranked Italian Berrettini to keep alive his hopes of reaching the semi-finals.

Federer got the job done without too much fuss and will now face great rival Novak Djokovic on Thursday as he bids to reach the last four.

The 38-year-old Swiss said: "It's unusual to lose and come back and play again but I did it last year, I had that experience, and I'm happy with how I played today.

"Matteo was always going to be tough with his big serve. To get that break at the start of the second set was key, and I was pretty clean on my own serve.

"Hopefully I can keep that up and play a bit better in my next match."

The task facing debutant Berrettini was daunting, to say the least. Federer has failed to reach the semi-finals at the season-ending tournament only once in 16 previous appearances. He had never been beaten in a second round-robin match and only lost once to a first-timer.

Berrettini, meanwhile, had taken just five games off Federer in their only previous meeting, a chastening three-set defeat at Wimbledon earlier this year.

The 23-year-old matched that figure in the first set here and then surpassed it by surviving the only break point at 5-6 to force a tie-break.

However, Federer dropped only two points in the tie-break and broke to love at the start of the second on his way to victory.

In the evening match, Thiem won a classic against Djokovic to book a place in the semi-finals for the first time in his career.

Austrian Thiem, ranked fifth in the world, lost the first set on a tie-break but conjured up arguably some of the finest tennis of his career to level the match and go a break up in the decider.

In a thrilling final set Djokovic broke back, but Thiem served for the match at 6-5, only for the Serbian to force another tie-break.

Thiem held his nerve to win one of the best 02 matches in many a year 6-7 (5-7) 6-3 7-6 (7-5) victory. 

Thiem said: "This was really one of those special matches that I practised all my life for, beating a legend of our game and qualifying for the semi-finals.

"I was in the zone from the first point, I served for the match at 6-5 in the third but I was playing one of the best returners so I didn't  worry about that. Then at 4-1 down in the tie-break I maybe had a bit of luck.

"I stayed in the match. It is special to come back from a set down, especially in a tie-break.

"I stayed offensive all the time even when it didn't always work out. I'm proud I reached my goal of the semi-finals."

Djokovic's defeat means his match against Federer on Thursday is a straight shoot-out for the second semi-finals spot.