If somebody told you at the end of the 24 Hours of Le Mans last year that the 2017 edition would have an equally shocking finale, you’d have laughed – and yet here we are. The #2 Porsche 919 Hybrid driven by Timo Bernhard, Earl Bamber and Brandon Hartley has clinched overall victory here in a race that has seen twists and turns all the way to the very end.

Toyota was the prime favourite to win, having locked out the front row of the grid and setting the lap record in the process. Indeed, the #7 TS050 Hybrid of Mike Conway, Kamui Kobayashi and Stéphane Sarrazin led throughout most of the first half, while the #8 Toyota of Sébastien Buemi, Anthony Davidson and Kazuki Nakajima and the #1 Porsche of Neel Jani, André Lotterer and Nick Tandy traded positions not far behind.

Trouble struck the #2 Porsche first just before the fourth hour, with the car developing a problem on the front electric motor; a similar issue then afflicted the #8 Toyota in the eighth hour. Both cars were pushed well down the order and seemingly out of contention of the podium, let alone a victory.

But worse was to hit Toyota. Just past midnight, after a safety car period, the #7 Toyota developed a suspected clutch problem while in the lead, leaving the car with no petrol power. Kobayashi tried desperately to nurse the car back to the pits using only electric drive, but it was not to be.

Within minutes of the #7 car retiring, the #9 Toyota of Nicolas Lapierre, Yuji Kunimoto and Jose Maria Lopez was involved in a collision while trying to chase the now race-leading #1 Porsche. This caused a puncture that did massive damage to the rear of the car, and it ultimately came to a stop just a couple of hundred of metres from the pit lane entry.

This was heartbreaking for Toyota – particularly after last year’s last lap horror show – and left the #1 Porsche unchallenged for the lead throughout the rest of the night. In fact, the latter was the only LMP1 car at the top of the pack, with the LMP2 cars following it more than 10 laps behind.

As the race reached its closing stages, however, Le Mans dealt its most devastating blow. With just four hours remaining, the #1 Porsche began to limp its way around the track due to low oil pressure, before coming to a stop – the dream was over for the hitherto unperturbed LMP1 car.

This set the showdown of the lifetime, as the #38 Jackie Chan DC Racing Oreca-Gibson LMP2 car driven by Ho-Pin Tung, Thomas Laurent and Oliver Jarvis was suddenly thrust into the overall lead of the race. Meanwhile, the #2 Porsche, which had clawed itself back up the order into fifth place, was five laps behind but was closing at a rate of around ten seconds a lap.

Slow zones threatened to hamper Bernhard’s progress, but the inevitable happened with just over an hour from the end, when the German overtook Tung and raced towards the chequered flag. With that, the #2 car brought home Porsche’s 19th overall victory – extending its record as the winningest manufacturer in the sport – and scored Zuffenhausen’s first hat trick since it rejoined the world’s oldest endurance race in 2014.

Behind the #38 car was the #13 Vaillante Rebellion Oreca-Gibson LMP2 of Nelsen Piquet Jr, David Heinemeier Hansson and Mathias Beche to complete the overall podium, while the #37 Jackie Chan car driven by David Cheng, Tristan Gommendy and Alex Brundle completed the LMP2 top three. The #8 Toyota, the sole other LMP1 car to complete the race, finished a lowly ninth place.

In the GTE Pro class, the #97 Aston Martin V8 Vantage GTE of Darren Turner, Jonny Adam and Daniel Serra took class victory after a fierce battle in the last few laps with the #63 Corvette C7.R driven by Jan Magnussen, Antonio Garcia and Jordan Taylor, which finished third. Swooping in to take second at the last minute was the #67 Ford GT of Andy Priaulx, Harry Tincknell and Luis Felipe Derani.

Lastly, Ferrari cleaned out the GTE Am podium, with the #84 JMW Motorsport 488 GTE of Robert Smith, Will Stevens and Dries Vanthoor finishing first ahead of the #55 Spirit of Race car of Duncan Cameron, Aaron Scott and Marco Cioci, as well as the #62 Scuderia Corse car of Cooper MacNeil, Bill Sweedler and Townsend Bell.