The Haas driver was on course to finish eighth having stretched out his final stint over 30 laps on a set of medium tyres on an audacious one-stop strategy as rival drivers suffered heavy levels of degradation.
Vettel was fighting back after a disastrous Aston Martin pit stop that took away any chance of finishing in the top six and had dropped as low as 13th in his final stint.
But by the final lap and on much fresher tyres, the German had closed up to Magnussen and attacked with DRS into turn 12.
Despite the Dane's best efforts and some stunning side-by-side racing through the final sector, Vettel secured the position around the outside at the triple-apex turns 16, 17 and 18.
Both drivers were later promoted a place after a Haas protest ended in a penalty for Fernando Alonso but addressing the battle, Magnussen said: "I have to say it was some driving from him, that’s when you really realise why he’s a four-time world champion.
"As much as it pissed me off it was impressive to see."
The result secured Haas' first home-race points since 2016 and Magnussen added: “I’m super happy.
"For us as a team, it’s very important to get these points at our home race in the US and it’s very big on the weekend that we announce a great title sponsor with MoneyGram - it couldn’t come at a better time."