Norway headed into the men's relay having tasted victory at every World Championships since 2001, and just one defeat since 1991, with Northug and Halfvarsson going head-to-head at the death.
Northug broke down the last descent before being caught and overtook by Halfvarsson, with the Swede leading right until the home straight in Val di Fiemme.
However he just didn't have enough in the final metres to stop Northug, who turned on the afterburners to finish 1.2 seconds ahead of the Swede.
That marked Northug's third medal after gold in the 15km freestyle and silver in the sprint while Russia beat hosts Italy for bronze by 0.2 in an even tighter race behind Norway and Sweden.
Norway trailed Germany by 0.3 after the first exchange with Japan, Sweden, USA, Finland and Italy all part of the chasing pack.
By the second exchange seven teams had become six and the order drastically changed as Switzerland led ahead of Italy before Russia, Germany, Norway and Sweden.
Just 4.1 separated first from sixth while by the third and final exchange there were effectively four teams battling for the medals with Russia leading.
All four were still in contention before final descent with Halfvarsson and Northug breaking away leaving Sergey Ustiugov to cruelly deny the home crowd as David Hofer and Italy had to settle for fourth.