Federer the world number two, saved four match points before defeating Stan Wawrinka, 4-6, 7-5, 7-6 (8/6), while world number one Djokovic emerged from his first serious test of the tournament with a 6-1, 3-6, 6-0 victory over Japan's Kei Nishikori.
Federer looked down and out when Wawrinka served for the match in the final set, but the six-time champion responded superbly and eventually booked his ninth appearance in the final of the season-ending event.
Djokovic had swept through the group stage in imperious style, but he was pushed harder by Nishikori, who became the first player to take a set off him since October, before a strong finish secured the Serb's fourth appearance in the final.
Djokovic, who has lifted the Tour Finals trophy three times, remains on course to become the first man to win the event three years in a row since Ivan Lendl in the 1980s.
The 27-year-old has now won 31 successive indoor matches, including 14 at the Tour Finals.
"Kei was playing great and this has been the best season of his life but he made some crucial double faults in the third set," Djokovic said.
Federer held his nerve impressively despite an erratic performance in the best match of a tournament sorely lacking memorable encounters this year.
The 33-year-old has now saved 11 match points in three winning causes this year, with the others against Gael Monfils at the US Open and Leonardo Mayer at the Shanghai Masters.
The 124th final of Federer's illustrious career is a rematch of this year's Wimbledon final, which Djokovic won in five sets.
Federer has met his great rival on 36 occasions, winning 19 times, but the world number one has won their last three finals, including at the Tour Finals in 2012.
"I think I got lucky tonight. Stan played better from the baseline and that usually does the job on this court. But I kept fighting," Federer said.
"It's tough but I'm thrilled to be in another final in London.
"Novak is playing great tennis. It usually brings the best out of me, it's going to be tough but I'll give it a shot."
Federer raced into the last four with a dominant run of three successive victories, for the loss of only 13 games, which peaked with a brilliant 6-0, 6-1 thrashing of Andy Murray on Thursday.
He had also won 14 of his 16 previous meetings with Wawrinka, who will join forces with his fellow Swiss for the Davis Cup final against France next weekend.
Yet there was no sign of any inferiority complex from Wawrinka took the first set.
A tense second set saw 11 successive holds of serve until Federer pressured Wawrinka into a pair of crucial errors that gifted him both the game and the set.
Federer immediately fell behind in a controversial opening game of the final set.
With Wawrinka leading 30-0 on Federer's serve, the world number four's shot was called out by a line judge, only for the umpire to quickly reverse the call.
But Federer didn't hear and instead of challenging the decision, he played on thinking he had won the point, only to discover he was 0-40 down when he lost the next point.
Federer remained visibly frustrated by the perceived injustice, adding another layer of drama to a thrilling finale.
Wawrinka had three match points when he served for a place in the final at 5-4, but Federer saved them all and eventually broke back.
In the tie-break Federer led 5-3, then had to save another match point before finally sealing a remarkable victory.