Often harsh, often unforgiving: that racing can be a cruel mistress was brought home to Ferrari’s Charles Leclerc with a bludgeon blow at the Bahrain Grand Prix. Lewis Hamilton may have won the race for Mercedes but it was Leclerc who captivated in this fascinating drama. Only 21 years old, with a first win in his grasp, he was denied at the last.

The Monégasque’s composure and skill on track and his extraordinary maturity in dealing with this harshest of slings and arrows confirmed this young man is a world champion in waiting.

Hamilton earned the win by doggedly sticking to his task despite lacking the pace of the Ferraris and his control was again in stark contrast to Sebastian Vettel’s. The German made an unforced error after which he could manage only fifth behind Red Bull’s Max Verstappen. Lando Norris was an excellent sixth for McLaren in front of Kimi Raikkonen’s Alfa Romeo. Pierre Gasly in the Red Bull was in eighth, with Toro Rosso’s Alexander Albon also impressive in ninth. Racing Point’s Sergio Pérez was 10th. Last season Vettel’s mistakes played a key part in his failure to take the title fight to the wire. His spin in Bahrain highlights that chink in his armour.

Leclerc, in only his second F1 season and his second race for Ferrari, showed no such weakness.

He had lost places from pole but held his nerve, fought back and retook the lead in a marvellous display of confidence and commitment, putting his four-times world champion team-mate to the sword.

Having built a solid lead, he looked nailed on for that debut win until he suffered a mechanical problem with the turbo energy recovery system with 11 laps to go. He lost pace and places, ultimately coming home in third behind Valtteri Bottas as Hamilton inherited the lead and took the win.

Leclerc is a prodigious talent who will doubtless go on to win. Head bowed before he emerged from his car, by the time he climbed out he had, like all the greatest drivers, already moved on. For all that the moment seemed to require theatrical emotion, Leclerc was a rock.

“Today was not our day. It’s sad because obviously I was so close of realising a dream that you have since childhood, which is your first win in Formula One,” he said.

“Hopefully this day will come one day in the future. I’ll work for that, the team will work for this, but they should be proud about what they’ve done this weekend and we’ll come back stronger.”

Hamilton now trails his team-mate Bottas by one point in the world championship. He had a poor start and had to come back at Bottas and, crucially, later go wheel to wheel with Vettel for second place. He came out on top while Vettel’s error damaged his tyres and ultimately destroyed his front wing.

Hamilton immediately acknowledged Leclerc’s misfortune.

“I was not expecting that result,” he said. “The Ferraris outpaced us all weekend. Big congratulations to Charles, he deserved the win today but you have to take it as it comes. I am proud of the job we did given the lack of pace we had.”

Hamilton told Leclerc that he had “a great future in front of you” before the podium ceremony . “I expected him to be great and do a great job,” said Hamilton. “Who would have known he would be so quick so early on but he is driving a Ferrari. He is doing a great job, fair play to him.”

The FIA president, Jean Todt, also expressed his confidence in the Ferrari driver on Twitter.

“Cruel conclusion for @Charles_Leclerc who dominated the race, but he will have the opportunity to win a lot of success in the future,” he wrote.

Third placed Charles Leclerc shows his disappointment. Photograph: Lars Baron/Getty Images

Ferrari will take heart from the pace their car showed but will be concerned by what cost them the win. They have denied the car suffers from cooling problems and the suddenness with which Leclerc’s issue occurred suggests this was not responsible.

The team principal, Mattia Binotto, recognised Leclerc’s drive and was optimistic that they can still challenge. “He did a great race obviously,” he said. “It’s disappointing but we need to look at the positives of the weekend and come back stronger.”

The Mercedes team principal, Toto Wolff, also acknowledged Leclerc’s drive but praised Hamilton who had done everything to stay in the game. “Charles was very unfortunate; he had the quickest car and then his fortune swung in the other direction,” he said. “Our strength is holding it together, even cruising home with a third or fourth might win you the championship.”

Vettel admitted he had made a mistake, a subplot of this drama in Bahrain that could yet prove vital come the final act of the season. Leclerc is now four points ahead of the German in the championship. Vettel is already 21 behind Hamilton and both these drivers of the old guard will be more than aware that Leclerc is likely to emerge from this crucible stronger than ever.