Vettel went to the pits for fresh rubbers and emerged ahead of the Briton as he claimed his his 48th career win and 100th podium finish in his 200th grand prix.
The German won from Hamilton and Kimi Raikkonen in the other Ferrari, giving the Scuderia a strong start into the campaign as they make another attempt to win a first Formula One drivers' title since 2007.
Vettel and Hamilton are chasing a fifth world title in the 21-race campaign.
“We got a bit lucky but we will take it. We’re not yet where we want to be, I don’t quite feel the car, but it gives us a good start, good wind and fresh motivation for the coming weeks,” Vettel said.
Hamilton said: "Today they did the better job. We have to go back to the drawing board and work on it. We still have great pace and during the race I could apply pressure but it is so hard to overtake here."
Mercedes motorsport chief Toto Wolff hinted that a software glitch could have been the reason for defeat.
"I think we have a software issue with the VSC data ... The gap that we needed was wrongly calculated by the systems," Wolff told Sky Sports UK. “It’s very hard to take because we had the pace."
Things looked good for Hamilton at first when he won the start from pole and gradually got a small advantage over Raikkonen and Vettel.
Haas' Kevin Magnussen passed the Red Bull of Max Verstappen for fourth place, and the Dutch contender then even dropped to eighth after a spin coming out of turn one in the 10th lap.
Raikkonen pitted first in the 18th, Hamilton followed in the next lap, while Haas met total disaster to ruin what had until then been a splendid weekend for them.
Magnussen had to retire right after his stop in the 22nd lap, and so did Romain Grosjean three laps later because on each occasion a wheel nut was cross threaded, forcing the drivers to stop their cars immediately.
Grosjean stopped his car on the side of the track which led to a virtual safety car - and later a full safety car - and more drama.
Vettel pitted and somehow found the precious seconds to emerge ahead of Hamilton and Raikkonen for the lead, with Hamilton and Mercedes puzzled why they lost out.
"I was praying for a safety car and then ... the Haas stopped in the exit of Turn Two and when I saw it I was full of adrenaline," Vettel said.
The German won the restart, Hamilton closed in on his rival in the late stages but with deteriorating rear tyres had to settle for second behind Vettel who won in 1 hour 29 minutes 33.283 seconds.
Home boy Daniel Ricciardo and Verstappen finished fourth and sixth respectively for Red Bull, with ex-champion Fernando Alonso in-between in fifth for a great start into 2018 for McLaren.
Valtteri Bottas was eighth in the second Mercedes, up from 15th on the grid following a qualifying crash and grid penalty.
The next race is April 8 in Bahrain.
The German won from Hamilton and Kimi Raikkonen in the other Ferrari, giving the Scuderia a strong start into the campaign as they make another attempt to win a first Formula One drivers' title since 2007.
Vettel and Hamilton are chasing a fifth world title in the 21-race campaign.
“We got a bit lucky but we will take it. We’re not yet where we want to be, I don’t quite feel the car, but it gives us a good start, good wind and fresh motivation for the coming weeks,” Vettel said.
Hamilton said: "Today they did the better job. We have to go back to the drawing board and work on it. We still have great pace and during the race I could apply pressure but it is so hard to overtake here."
Mercedes motorsport chief Toto Wolff hinted that a software glitch could have been the reason for defeat.
"I think we have a software issue with the VSC data ... The gap that we needed was wrongly calculated by the systems," Wolff told Sky Sports UK. “It’s very hard to take because we had the pace."
Things looked good for Hamilton at first when he won the start from pole and gradually got a small advantage over Raikkonen and Vettel.
Haas' Kevin Magnussen passed the Red Bull of Max Verstappen for fourth place, and the Dutch contender then even dropped to eighth after a spin coming out of turn one in the 10th lap.
Raikkonen pitted first in the 18th, Hamilton followed in the next lap, while Haas met total disaster to ruin what had until then been a splendid weekend for them.
Magnussen had to retire right after his stop in the 22nd lap, and so did Romain Grosjean three laps later because on each occasion a wheel nut was cross threaded, forcing the drivers to stop their cars immediately.
Grosjean stopped his car on the side of the track which led to a virtual safety car - and later a full safety car - and more drama.
Vettel pitted and somehow found the precious seconds to emerge ahead of Hamilton and Raikkonen for the lead, with Hamilton and Mercedes puzzled why they lost out.
"I was praying for a safety car and then ... the Haas stopped in the exit of Turn Two and when I saw it I was full of adrenaline," Vettel said.
The German won the restart, Hamilton closed in on his rival in the late stages but with deteriorating rear tyres had to settle for second behind Vettel who won in 1 hour 29 minutes 33.283 seconds.
Home boy Daniel Ricciardo and Verstappen finished fourth and sixth respectively for Red Bull, with ex-champion Fernando Alonso in-between in fifth for a great start into 2018 for McLaren.
Valtteri Bottas was eighth in the second Mercedes, up from 15th on the grid following a qualifying crash and grid penalty.
The next race is April 8 in Bahrain.