It was like a scene from an action movie, except totally unscripted and genuinely life-threatening, involving a stunning escape that Harry Houdini would have struggled to match.

Formula One driver Romain Grosjean was trapped in a burning car after it sliced in half and exploded into a fireball, following a crash on the first lap of the Bahrain Grand Prix on Sunday.

As flames tore into the desert night sky, Grosjean was inside a raging furnace for about 10-15 seconds.

Somehow, the quick-thinking Frenchman did not give in to panic.

Somehow, he was lucid enough to find a way out.

Jumping through the flames like an action hero, he then grabbed the molten-hot metal barrier in front of him and hurdled over it onto the track.

Safe though visibly shaken, he was well enough to walk to the ambulance with the help of two medics.

He was treated for minor burns to the back of both hands but was well enough to speak from his hospital bed late Sunday, in a video posted by F1.

“Just wanted to say I am OK,” a smiling Grosjean said. “Thank you very much for all the messages.”

The relief at the time of the incident, for his distraught teammate Kevin Magnussen and others watching from the paddock, was immense. Drivers and other team members spontaneously applauded.

“I saw a lot of fire and thought that is not a good thing,” Red Bull's Max Verstappen said. “Luckily he is OK and hopefully he will recover.”

The 34-year-old Grosjean clambered out of the burning wreckage with his race helmet and fireproof race tunic singed as track marshalls sprayed him with a fire extinguisher.

“I want to thank the rescue crews who are very quick,” Haas team principal Guenther Steiner said. “The marshals and FIA people they did a great job, it was scary.”

As Grosjean was taken by helicopter to a military hospital, where he was being kept overnight, drivers reacted to the jarring scene.

“The car, the cockpit. I don't know what Gs he pulled but I'm just so grateful the halo worked,” said F1 champion Lewis Hamilton, who won the restarted race. “It shows what an amazing job Formula One has done, the FIA has done, for him to be able to walk away from something like that.”

Countryman Pierre Gasly, who drives for AlphaTauri, was left in shock.

“It was horrible, really scary. I had no idea a Formula One car could break that way,” Gasly said. “I have texted him to wish him a good recovery. I think he is fine but a really scary thing.”

Hospital X-rays showed Grosjean did not even break a bone, despite an estimated impact speed of 200 kph (125 mph).

But had he not managed to wriggle free, pulling him out of the cockpit would have been extremely difficult.

“I've never seen that much fire in 12 years. It took a little while to process what was going on but then Romain started to get out of the car himself, which was amazing,” said Alan van der Merwe, the driver of the F1 medical car. “Everything worked hand in hand today: the halo, the barriers, the seat belt. Without one of the things it could've been a different outcome.”

The halo is a safety device that forms a protective ring around the drivers' head. It was introduced following the death of French driver Jules Bianchi after he sustained massive head trauma on a rain-soaked track at the Japan GP six years ago and went headfirst into a trackside crane. Two years ago Charles Leclerc - Bianchi's close friend - was likely saved serious injury or death by the halo when another car landed on top of his at the Belgian GP.

Hamilton and Verstappen were not initially fans of the halo.

Things have changed.

“I think the halo saved his life,” Verstappen said. “When it came onto the cars I was quite critical about it and it looked ugly. But you can't say anything about the safety because today it definitely saved Roman.”

The best-placed person to confirm that was Grosjean himself.

“I wasn't for the halo some years ago,” he said. “But I think it's the greatest thing and without it I wouldn't be able to speak to you today. Thanks to all the medical staff at the circuit and the hospital”

His accident happened when he slid to the right and his back wheel clipped the front of Daniil Kvyat's AlphaTauri, causing Grosjean to fly sideways into the barrier.

“If everyone else is shocked, just imagine how his family's feeling (at the time),” Hamilton said. “The flames, the car broken in two and not knowing where the driver is, and him popping out from those flames. I can't imagine what that's like.”

It reminded Hamilton of a traumatic experience from his junior karting days.

“When I was nine I saw a kid die on the same day I won a race. So I've always been aware of the dangers and the risks,” Hamilton said. “I'm also thinking of Roman. He's got a wife and kids, that must be something he will have to think heavily on. Because it's a privilege to be able to do what we do, but there's so much and so many other things to do.”