The #7 Toyota eventually ended up being classified two laps down on the winning vehicle because Kobayashi lined up behind Nakajima for a formation finish at the chequered flag.
Toyota have secured victory in the Le Mans 24 Hour race at their 20th attempt, as a team made up of Fernando Alonso, Sebastian Buemi and Kazuki Nakajima led them to the title for the first time. Both cars ran reliably, with Alonso and his crew running second for much of the opening stint before the Spaniard delivered a stunning spell overnight to reduce the deficit, before Nakajima passed Kobayashi to seize a lead they would never relinquish.
"Le Mans once a year is not enough!"
Although the final rankings may make it look like an easy win, with some substantial leads, it wasn't the case as Toyota's number eight was involved in an early crash with a Rebellion auto.
The presence of a sporting icon at Le Mans guaranteed the race, Toyota and the WEC far greater worldwide attention than had it been six lesser-known drivers competing in what was effectively a private Toyota battle.
But in a series of stints in the dead of night, Alonso clawed back the deficit and put the number eight auto right back on the tail of the number seven.
They started from pole position on Saturday afternoon after Japanese former Williams driver Nakajima posted the fastest time in qualifying for their number eight auto.
In an era when modern drivers tend to specialise in one category, such is the demand of the individual championships, that it would be a remarkable achievement for Alonso.
Jenson Button, the 2009 F1 world champion, was competing in the non-hybrid LMP1 class for the Russian SMP team.
The Spaniard left Ferrari at the end of 2014 having lost faith in their ability to deliver a title-winning vehicle, only to find that McLaren-Honda were in far worse shape.
Expected to dominate the 86th edition of the race, as the only major manufacturer in the top LMP1 category after champions Porsche withdrew a year ago, Toyota's victory came at the 20th attempt.
Three years of poor reliability and performance, and an apparent lack of interest in signing the ageing champion from the top three teams, broadened his outlook beyond F1.
Alonso now just needs to win the Indy 500.
In 2016, Nakajima had also been heading for victory when he slowed with five minutes remaining and came to a halt with victory falling into Porsche's lap.