Seeking a ninth title at Basel - where he has once a ball boy and reached the final in his last 11 appearances - Federer last dropped a set in his opening match 10 years ago.
Copil upset expectations of a Federer final against Alexander Zverev in a 6-3, 6-7 (6), 6-4 win over the fifth-ranked German in the earlier semifinal.
Federer started his slow recovery with a break for 4-5; he then saved set points to level at 6-all, winning a game in which he double-faulted twice in a row and saved a set point with an ace.
The eight-time champion and hometown hero needed 2 hours and 36 minutes to complete the victory 7-6 (1), 4-6, 6-4, as the first set took more than an hour alone.
After dropping the second set, the world No. 3 grabbed a break of serve early in the decider only to hand it back with a sloppy service game of his own, reports Efe news. "It was dream run for me", Federer said in his acceptance speech, before his fans' ovation brought tears welling in his eyes.
Copil made 31 unforced errors and crumbled when the pressure was highest, allowing Federer to recover from a break down in the second set and win the last five games as the Romanian's challenge ran out of steam.
The 28-year-old Copil came to Basel with career prize money - $1.67 million - significantly less than Federer earned just for winning the Australian Open in January.
It is Zverev's 52nd win of the season and a ninth semi-final spot for the world number five, who has already qualified for the season-ending ATP Finals in London next month. Federer though was fortunate to win the set even after making almost 30 unforced errors.
"I'm very happy. I think it was my best performance this week", Federer said.
In 150 tour-level finals, Federer has never lost to someone ranked as low as Copil, who also beat world No.6 Marin Cilic en route to his second ATP final.