Porsche pulled off a miracle finish at the 2017 24 Hours of Le Mans on Sunday when it’s No. 2 919 Hybrid LMP1 driven by Earl Bamber, Timo Bernhard and Brendon Hartley crossed the finish line first, despite being stuck in the pits for over an hour at one point.

The miracle was made possible due to reliability problems that plagued Toyota’s TS050 Hybrids. Hopes were high of a first Toyota win when the pole position-winning No. 7 TS050 Hybrid led for the opening 10 hours, but a clutch problem meant the car had to retire.

The No. 8 TS050 Hybrid had also been in contention for almost eight hours until an issue on the front motor cost it almost two hours in the pits. It rejoined and finished ninth, setting the fastest lap late in the race. Recall, Toyota missed out on the overall win last year—in the closing minutes!—also due to reliability problems.

No. 8 Toyota TS050 Hybrid at the 2017 24 Hours of Le Mans

No. 8 Toyota TS050 Hybrid at the 2017 24 Hours of Le Mans

Toyota’s No. 9 TS050 Hybrid was knocked out of this year’s race when it was hit from behind by a LMP2 car. It, too, was forced to retire although was never in contention.

Porsche had reliability problems of its own. Its No. 1 919 Hybrid led for much of the race, and even built a 13-lap lead at one point, though it came to a stop due to a lack of oil pressure and was forced to retire. And the winning No. 2 car, as mentioned, was in the pits for over an hour, due to a front motor problem.

This led to some brilliant racing. Having rejoined the field 18 laps behind the leader, at 56th, the drivers of the No. 2 919 Hybrid sliced through the field, thanks mostly to the efforts of Hartley. On lap 330 for the No. 2 car, an LMP2 was still in the lead. Then, on lap 338, Bernhard took the lead. His penultimate fuel stop was after 351 laps, after which he made a final splash & dash. After 367 laps in total, Bernhard took the checkered flag.

The win was Porsche’s 19th overall in the French endurance classic, further reinforcing the German firm’s status as the top manufacturer in sports car racing.

The lack of LMP1s finishing meant second and third spots went to teams competing in the LMP2 class. In second was the No. 38 Jackie Chan DC Racing Oreca 07 of Ho-Pin Tung, Thomas Laurent and Oliver Jarvis. While in third place was the No. 37 Jackie Chan DC Racing Oreca 07 of David Cheng, Tristan Gommendy and Alex Brundle.

No. 97 Aston Martin Vantage GTE at the 2017 24 Hours of Le Mans

No. 97 Aston Martin Vantage GTE at the 2017 24 Hours of Le Mans

In the GTE Pro class for production-based cars with professional drivers, Aston Martin reigned supreme, albeit thanks to a little luck. The British firm’s No. 97 Vantage GTE driven by Jonny Adam, Darren Turner and Daniel Serra took a dramatic win by moving into the lead spot only on the final lap. In second place was the No. 67 Ford GT of Chip Ganassi Racing while in third was the No. 63 Chevrolet Corvette C7.R of Corvette Racing.

With just over 45 minutes left on the clock, the No. 97 Vantage GTE and No. 63 Corvette C7.R came in for final fuel stops around the same time. With both cars exiting the pit lane together, with the Corvette on front, the battle was on. The Corvette looked like it was going to win, but on the final lap a tire puncture meant the car started to slow, allowing the Vantage to pass. This also allowed the #67 GT to catch up and move into second.

With the Le Mans race, round three of the 2017 World Endurance Championship, now over, Bamber, Bernhard and Hartley now move into the top spot of the 2017 Drivers’ Championship with 83 points apiece. In the Manufacturers’ Championship, Porsche leads with 111 points. Among the GT classes, Andy Priaulx, Harry Tincknell and Luis Felipe Derani lead the Drivers’ Championship, while Ford and Chip Ganassi Racing lead the Manufacturers’ and Teams’ Championships, respectively. The next race on the calendar is the 6 Hours of Nürburgring in mid-July.

This story has been updated due to the disqualification of the No. 13 Vaillante Rebellion Oreca 07 of Nelson Piquet Jr, Mathias Beche and David Heinemeier Hansson. The LMP2 car had finished third overall but was disqualified post-race due to an illegal alteration of the body done to save time.