Thorgan Hazard's early double left Switzerland needing to win by two goals to qualify from Group A2 but the hosts quickly fought back, with Ricardo Rodriguez's penalty and Seferovic's first two goals seeing them into a 3-2 half-time lead.
Nico Elvedi nodded home a Xherdan Shaqiri cross in the 62nd minute, and Vladimir Petkovic's men sealed a stunning win when Seferovic completed his treble late on.
Switzerland's victory against the team ranked number one in the world by Fifa came just days after the team was lambasted for losing 0-1 to Qatar, ranked 96th in the world, in a friendly at home. Switzerland are currently ranked eighth by Fifa. They made it to the last 16th of the World Cup in summer before bowing out to Sweden in a disappointing performance.
“I want to congratulate each player, there was a big mental reaction, the players never gave up, they always believed,” said Swiss coach Petkovic. “They played with will, intelligence and with their heads.”
After a thrilling match that continued a trend of goal-filled encounters in the inaugural edition of the Nations League, Switzerland will play at the finals in June next year, alongside European champions Portugal and England, with the final spot going to either France or the Netherlands on Monday.
Roberto Martinez's men saw their six-match unbeaten run since reaching the World Cup semi-finals brought to an shuddering halt.
“We forgot to defend well, we gave Switzerland the opportunity to get back in the game,” said Spanish coach Martinez.
“We had a lot of excitement, we really wanted to finish top of the group. The disappointment will make us more focused when the (Euro 2020) qualification starts.”
Thorgan Hazard sets the tone
Thorgan Hazard set the tone for the game in only the second minute as dreadful defending by Swiss centre-back Elvedi allowed him to slot home.
The 25-year-old winger continued his excellent recent form with a magnificent individual strike in the 17th minute, carrying the ball forwards at pace before hammering a low drive into the bottom corner from the edge of the box.
The Borussia Moenchengladbach man has now scored 12 goals for club and country this season.
That left the hosts with a mountain to climb, but Rodriguez got them on the score sheet in the 26th minute from the spot after Nacer Chadli fouled Kevin Mbabu.
Liverpool forward Shaqiri was starting to have a bigger impact on the game and he headed the ball across goal for Seferovic to tap in his first just after the half-hour mark to keep the game alive.
Benfica striker Seferovic sent the crowd in Lucerne into raptures with a wonderful curling finish shortly before half-time as a famous fightback beckoned.
Switzerland continued to press at the start of the second period, with Shaqiri bending a free-kick narrowly over the crossbar.
Shaqiri, who has been revitalised since joining Liverpool from Stoke in the close season, was the architect of the all-important fourth goal, creating space for a whipped cross which only needed a glancing touch from Elvedi.
Belgium still only needed one goal to snatch top spot in the group, but Seferovic put that beyond reach of the away side by twisting to head home in the 84th minute.
There was still time for Switzerland goalkeeper Yann Sommer to be forced into saves by Eden Hazard and Belgian substitute Michy Batshuayi, but the hosts held on and almost scored a sixth when Denis Zakaria was denied at point-blank range by Thibaut Courtois.