Longwell's 31-yard kick put the Vikings, who had blown a 17-point lead, back in front with 1:56 remaining. The Ravens' Steven Hausch then missed a 44-yard field goal attempt as time expired.
Baltimore scored 21 points in the fourth quarter.
Longwell's other field goals were from 40, 22 and 30 yards.
Joe Flacco passed for 385 yards and two touchdowns and Ray Rice ran for 22- and 33-yard touchdowns for Baltimore (3-3).
Exploding whale video goes viral on Internet
Video of Victoria’s Secret models trying to 'twerk' hits Instagram