LONDON — A set up against a man he'd never lost to, Roger Federer looked to be cruising toward a shot at a seventh ATP Finals title. David Goffin had other ideas.

The Belgian rallied in the semifinals on Saturday to claim the biggest win of his career and stun the favourite 2-6, 6-3, 6-4.

"It is the best win of my career, for sure," said Goffin, who lost all six of his previous encounters against Federer.

"I started to feel the ball better at the end of the first set, so I wanted to be more aggressive. It paid off. I started to serve well. My forehand was going much better."

His opponent on Sunday in the final will be Grigor Dimitrov after the Bulgarian defeated Jack Sock 4-6, 6-0, 6-3.

With Federer having lost just four times during a season that saw him claim his 18th and 19th Grand Slam titles at the Australian Open and Wimbledon, it looked ominous for Goffin when the six-time champion broke twice on his way to winning the first set.

However, Federer wasted two game points in the second game of the second set. Goffin produced a forehand passing shot to take his first break point of the match.

"It was a tough game to get broken at 1-0," Federer said. "I had I think multiple game chances to get out of the game and go 1-1, keep the pressure up. Things really turned around for him at that moment."

The winners flowed from Goffin's racket, unsettling Federer, who coughed up uncharacteristic errors.

Goffin needed just the one break in both the second and third sets and displayed a previously unseen grit to deny Federer his lone break point opportunities in either set.

It was testament to the remarkable season Federer has put together that his loss came as such a major surprise.

However, neither the loss to Goffin nor the fact he finishes the year second, behind Nadal in the rankings, will prevent him from being favourite for the Australian Open in January.

"It's been an amazing year for me," Federer said. "Been so happy that I was playing at this level from the beginning till basically the end, till today."

The match was typical of Goffin's inconsistent week on his full debut at the tournament, after he played one match as an alternate a year ago.

After defeating a wounded Rafael Nadal in his opening match, he was thrashed in just 74 minutes by Dimitrov, and qualified for the semis with a comfortable win over Dominic Thiem.

"Both are really special," said Goffin, after becoming only the sixth man to defeat Nadal and Federer in the same tournament. "It was the first time against Rafa. Then the semifinal for the first time for me here, and to beat Roger for the first time here in such a big event, big tournament, it was the perfect moment."

Dimitrov ensured he'll end the year at a career-high No. 3 after coming from behind to defeat Sock.

Having won his previous two matches for the loss of just four games, Dimitrov's title credentials were given a far more rigorous examination by the American.

Dimitrov is the first debutant to reach the final since David Ferrer in 2007.

Goffin will be the underdog again after winning just two games against Dimitrov on Wednesday.

"It will be something different hopefully," said Goffin, who can move to a career-high No. 5 if he claims the title. "I hope to play the tennis I played today. I'll try to be more aggressive, also go for the shot, and yeah, go for the trophy."