Sebastian Vettel won a dramatic Australian Grand Prix after leapfrogging Lewis Hamilton during a safety car period.

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.

A pit stop made under the virtual safety car takes 10 seconds less than one made when the cars are at full speed and the time gain of stopping while Hamilton was restricted on track allowed Vettel to rejoin the race just ahead of the Mercedes.

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.

It was a bitter blow for Hamilton in the first race of a year in which he hopes to beat Vettel to be the first driver of the current era to win a fifth world title.

That's three wins in Australia for Vettel, level with Jenson Button. Source: Forix

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.

Dear F1: Please, please, PLEASE be more unpredictable

Bizarre Haas error helps out 'mother' Ferrari

Kevin Magnussen and Romain Grosjean were running fourth and sixth from the start of the race - and that became fourth and fifth when Max Verstappen spun his Red Bull at Turn One on lap 10, caught out by a handling imbalance created by damage to the floor caused when he ran wide at Turn 12 on lap six trying to pass the Dane.

But both were forced to retire when the mechanics sent them out after their pit stops with loose wheels, caused by the wheels not being positioned correctly before the nuts were tightened - for which they will were hit with a 10,000-euro fine by governing body the FIA.

Team boss Gunther Steiner blamed a lack of pit stop practice as a result of time lost to fixing problems on the car during the weekend.

First Magnussen pulled off at Turn Three on lap 22 and the same fate befell Grosjean when he stopped two laps later.

But while Magnussen parked in a place his car could be recovered, Grosjean did not - abandoning the Haas on the straight between Turns Two and Three.

First the virtual safety car (VSC) was imposed to control the field while officials tried to recover it and then - after Vettel had taken the lead - it became a full safety car period.

Haas were running well in fourth and fifth before the cars failed to have their front-left (Magnussen) and rear-left (Grosjean) wheels secured properly during the pitstops

'Did I do something wrong?'

Hamilton asked his team whether he had done anything wrong, and they told him they were looking into what happened.

Afterwards team boss Toto Wolff said Mercedes' computer systems had calculated wrongly the time gap Hamilton needed to ensure he had enough of an advantage to keep the lead under a VSC.

Wolff said: "We thought we had enough margin to beat Sebastian but then we saw the TV pictures and it wasn't enough. I think it must have been a software problem somewhere in our system."

He said the only thing Hamilton could have done had they had different data would have been to build a bigger gap in the six laps between his pit stop and the VSC - which they would have asked him to do despite the risk it would have created of wearing the tyres too much for the end of the race.

Hamilton said he could have gone quicker but added: "It was not easy at all to pull away from him in the first part of the race."

The margins were small - Vettel was only just over a second ahead when he emerged from the pits - but enough to be decisive.

After 15 laps of following Vettel closely, Hamilton asked his team: "Can I push yet? Let me know how much you want it." A pause. "I'm going for it."

He then set his fastest first sector time so far on lap 47, only to lock up badly and run wide into Turn Eight, and drop back nearly four seconds.

He closed back up to within a second by lap 51, with seven to go, but then began to drop back and the win was finally gone.

The race to a career-defining fifth title is under way - and Vettel has an unexpected advantage

'I don't understand'

"I don't understand what's happened. I did everything I believe I was supposed to do. The safety car came out and I was coming down the straight and then really last minute I was told the Ferrari was coming out. I didn't know it was in but I thought I had the delta.

"I was keen to recover from whether it was a mistake or not and I was risking it all but eventually I had to make the sensible choice there is a long way in the championship and it is not all won in one race."

"Obviously we got a bit lucky with the safety car but I really enjoyed it," said Vettel. "Towards the end of the first stint I lost a bit of connection to Lewis and Kimi.

"I felt better on the soft tyres. I was praying for a safety car and then when I saw the Haas stopped I was full of adrenaline. They told me it was really close with Lewis, but I knew it was difficult to overtake."

It's not hard to see why Melbourne is a popular choice for an F1 race - 94,500 attended today's race

McLaren benefit from safety car

As he slowed in the final laps - Mercedes blaming his rear tyres going off - he began to fall back towards Raikkonen.

The Finn began to close at more than a second a lap but Hamilton did just enough to maintain second place.

Raikkonen found himself under heavy pressure from Red Bull's Daniel Ricciardo from the safety car to the end of the race but held the Australian off.

McLaren's Fernando Alonso was another to benefit from the caution period. He ran 10th in the first part of the race, but ran long like Vettel and emerged fifth.

Verstappen passed him under the virtual safety car as Alonso emerged from the pits but the Dutchman was told to give the place back because he had broken the rules forbidding passing under caution.

Like Raikkonen and Ricciardo, Alonso was under pressure from Verstappen for the rest of the race but he held him off to take a fifth place for McLaren in their first race with Renault engines.

Driver of the day

More a driver of the weekend - Lewis Hamilton. His pole lap was jaw-dropping, and he drove consummately in the first part of the race. He lost out on victory only because of a miscalculation by his team.

What happens next?

From Australia, the teams go to Bahrain in two weeks' time, a very different track from Melbourne, in a desert rather than a city, where overtaking is possible and tyre wear heavier.

Hamilton has a chance to make amends and it will be fascinating to see how the cars measure up.

All this reminds me of...

...1986: Nigel Mansell's Australian GP tyre blow-out in Adelaide dramatically cost him the world title, but it was your most memorable moment in a BBC Sport poll, with 40% of the vote

'Grid kids' replaced the traditional and controversial 'grid girls' - part of owner Liberty Media's attempts to modernise the sport

Verstappen was frustrated early on having lost a position to Magnussen's Haas, spinning at Turn 1

Hamilton's team-mate Bottas crashed during qualifying - piling the pressure on himself