The former world number one and seven-time Wimbledon champion broke Fognini's serve in the sixth game of the first set and quickly asserted himself on the match as he wrapped up the opener 6-2.
Federer looked to be taking a stranglehold on proceedings as he earned three break points on the Italian's serve in the second game of the second set, but Fognini showed resolve to win the game and keep his country's hopes of reaching the Davis Cup final alive.
The Swiss star wouldn't be denied and broke late in the set before serving out to win the second 6-3 and leave his country within touching distance.
Fognini tried to spark a fightback, putting pressure on Federer's serve early in the third set and forcing the 17-time Grand Slam winner to save three break points.
In the end, Federer took the set to a tie-break which he won 7-4 to book Switzerland's place in the final.
They will face France, who had already , giving them an made sure of their place by winning Saturday's doubles against the Czech Republic.