The six-time champion faced a straight shootout with Juan Martin del Potro at London's O2 Arena for second spot behind Novak Djokovic in Group B.
Of all Federer's qualities, it was his ability to battle that served him the best as he fought back from a break down in the second and third sets to win 4-6 7-6 (7/2) 7-5.
That set up a 32nd meeting with his old rival Nadal, who had the advantage of a day off on Saturday.
History certainly favours the Spaniard, who leads their head-to-head 21-10 and has won 13 of their last 17 matches, including all three this year.
While Federer has endured his worst season for more than a decade, Nadal has returned from serious injury to win 10 titles and reclaim the number one ranking.
The main source of encouragement for Federer is that he was won all four of their previous matches indoors, including both times they have met at the O2.
Federer said: "I just feel like I need to look at it more as being an underdog a little bit because of circumstances, because of my year, because of his year. Maybe that free swinging is what I need to do a little bit more tomorrow.
"We know each other that well. He's going to do exactly what he needs to do, I'm going to try to do what I need to do. Hopefully it's going to match up good for me. If not, he deserves it. He's had a wonderful season."
For most of the clash with Del Potro it looked like it would be the Argentinian who would be going through to meet Nadal.
Federer's forehand was a liability as he lost five of the first six games but he found his form in time to make it a close first set, missing two chances to level at 5-5.
Del Potro broke in the third game of the second set to take a stranglehold on the match but a run of 12 straight points got Federer back on track and he played an impressive tie-break.
The Swiss gave back the initiative when he was broken again at the start of the third set but once more he fought back and a break to lead 6-5 put him ahead for the first time in the match.
Del Potro had one chance to force a tie-break but could not take it and Federer clinched victory with his 10th ace.
The comeback was another sign of Federer's improving confidence, with three of his four victories over top-10 players this year having come in the last eight days.
Asked how he felt at 3-0 down in the decider, Federer said: "I fought back the whole match. I was thinking, 'Here we go again'.
"I was really getting angry at myself, how could I play a loose game, why is this happening?
"Because of the last few weeks probably I stayed relatively calm inside because I had a lot of ups and downs throughout the matches in Basel and in Paris, then again here.
"I wasn't in many of Juan Martin's service games so I felt like probably I would get one more chance to break back. It's exactly what happened. Once on even terms, I was able to play a little bit more freely.
"It was a great finish. I was very happy. To get the victory was a great feeling."
Del Potro is the only player other than Federer, Nadal, Novak Djokovic and Andy Murray to win a grand slam in the last 35 tournaments, and many within tennis believe he will be the one to break their stranglehold again.
The Argentinian was frustrated he could not take his chances against Federer, but said: "I think I had a great season.
"For this year my goal was to try to play at the same level as the top guys. I am the only player who beat all of them this season, which means something for me."
Sunday's other semi-final pits defending champion Novak Djokovic against Stanislas Wawrinka, who will be looking to end a 13-match losing streak against the Serbian.
The pair have played two of the best matches of the season, with Djokovic winning five-setters at the Australian and US Opens.
Wawrinka has made the last four on his debut, and Federer said of his countryman: "I don't know if I'm more excited that I won or we're both in the semis. It's historic."
Djokovic finished his group campaign with a 7-6 (7/5) 4-6 6-3 victory over Richard Gasquet to extend his winning run to 20 matches.
The Frenchman took a set against his rival for the first time since 2007, and Djokovic admitted it was difficult to motivate himself for a dead rubber ahead of Sunday's semi-final against Wawrinka.
The world number two said: "Three wins is the best possible ending of the group stage, even though today it was mentally challenging for me to approach this match.
"I had to stay motivated and tough and try to play on a high level through the whole match, which I didn't. There were a lot of ups and downs and it was a dull match in a way but I managed to find my best tennis when needed.
"I know what I need to do and hopefully I can perform against Stan as well as I did last week in Paris."
Gasquet delighted the packed crowd with his performance, which was all the more impressive considering on Friday his Italian coach Riccardo Piatti dramatically ended their working relationship.
Gasquet said he was "shocked" by the news and will now work solely with former world number four Sebastien Grosjean.
"He wanted to do different things in his life and his tennis career," said Gasquet. "I had to respect that. That's tennis and that's life."