From left, Brendon Hartley, Earl Bamber and Timo Bernhard have taken the World Endurance championship with Porsche for the second time. File photo: David Vincent / AP

Shanghai, China - New Zealander Brendon Hartley, who made his Formula One debut with the Toro Rosso team in October, has won the World Endurance Championship with Porsche for the second time.

Hartley, fellow Kiwi Earl Bamber and Germany's Timo Bernhard took the No.2 Porsche to second place in the penultimate round of the series in Shanghai on Sunday to secure the title.

Porsche, which will leave the championship at the end of the 2017 season, also took the Manufacturers' crown for the third consecutive year.

Toyota won the race with Japan's Kazuki Nakajima, Britain's Anthony Davidson and Swiss racer Sebastien Buemi.

Le Mans 24 Hours winner Hartley, who also won the world championship in 2015 with Bernhard and Mark Webber, is set to complete the Formula One season with Toro Rosso after making his debut at the US Grand Prix. He also looks likely to be confirmed for 2018 alongside French rookie Pierre Gasly.