The Mercedes driver was in control of the race until Romain Grosjean's Haas stopped on track and officials imposed a virtual safety-car, which restricts the pace of the cars on track.
The world champion had already made his pit stop but Vettel had yet to make his - and Ferrari pounced on the opportunity.
Hamilton tracked the Ferrari closely for much of the rest of the race but was unable to pass, before he dramatically lost pace in the closing laps and had to focus on maintaining second.
How did it go wrong for Hamilton?
Until the virtual safety car intervention, Hamilton had appeared in total control of the race after taking a blistering pole position by nearly 0.7 seconds on Saturday.
He led away from pole and stretched a 3.3-second lead over Vettel's team-mate Kimi Raikkonen, who qualified second ahead of the German, before the Finn made his pit stop on lap 18.
Hamilton followed him in on the next lap and rejoined with a bigger lead - but Ferrari decided to run Vettel long, taking advantage of their opportunity with two cars running at the front to split their strategies.
The decision would have been made in the hope of an incident bringing out the safety car - and their gamble paid off thanks to a bitter blow for Haas, effectively a Ferrari B team.