New Zealand's Brendon Hartley has won the world endurance championship in Bahrain alongside Porsche teammates Mark Webber and Timo Bernhard.

The trio took the title after his number 17 Porsche finished fifth in the Six Hours of Bahrain on Sunday (NZ time).

The Australian-New Zealand-German trio, who had to make two unscheduled pit stops, prevailed by five points to became Porsche's first world sportscar champions since 1986.

SUPPLIED New Zealand's Brendon Hartley nervously watches the final stages of the World Endurance Championship race.

The Bahrain season-ender was won by the number 18 Porsche of Switzerland's Neel Jani, Germany's Marc Lieb and Frenchman Romain Dumas - a victory that ensured the title for the sister car by denying rivals Audi.

"We had a lot of problems and it was very stressful. We got the car home and we had enough points and enough wins to be world champions," said Webber, who left Formula One at the end of 2013 after Red Bull team mate Sebastian Vettel had won a fourth successive championship.

The number 17 started with Bernhard behind the wheel but he was forced to pit on lap 17 with a loss of engine power from an engine actuator problem. The car lost 8 minutes 43 seconds and rejoined 4.5 laps down.

The leader had completed 52 laps when Bernhard made his planned stop, still four laps behind but back in the top 10 in the 32 car field.

Hartley took over on fresh tyres and raced through to the 114th lap - with a fuel stop after 79 - before handing over to Webber with the car in fifth place.

Webber remained at the wheel through a fuel and tyre stop on the 144th lap before the actuator problem flared again on lap 154 forcing another pit stop. There was another slash and dash stop in the 183rd lap as Webber held on to fifth.

Hartley said he drove two clean stints "driving flat out" in an attempt to catch the two Toyotas as he knew every second could be crucial.

"The boys in the pits did a fantastic job to get us out again and, of course, it was absolutely crucial that our sister number 18 car stayed in the lead. A true team effort! Incredible," the 25-year-old Kiwi added.

-Reuters and Stuff.co.nz