In his first driving stint on Saturday, Alonso made two breathtaking overtaking manoeuvres to pinch first place from the other Toyota, No 7, with Argentine Jose Maria Lopez at the wheel.
The two-time Formula One World Champion completed a quadruple stint and ran until 4 am, regularly lapping up to five seconds per lap faster than Lopez in the #8 auto.
McLaren F1 driver Alonso won the Monaco Grand Prix in 2006 and 2007 and requires just the Indy 500 to emulate Britain's double F1 champion Graham Hill, who is the only driver to have completed the Triple Crown set. "It has been our dream to win Le Mans and finally we have achieved it", he said.
Late at night, after Buemi drew a one minute "stop and go" penalty, Alonso took over and sparkled in the darkness as he closed the gap.
The started the race from pole position and never looked back, going on to dominate the race with a 1-2 finish.
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.
Aussie Matt Campbell won the GTE Am class
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.
The triumph, expected after champions Porsche withdrew previous year, came at the 20th attempt for Toyota who became only the second Japanese manufacturer to win the world's greatest endurance race after Mazda in 1991.
The only Toyota problem this weekend came 90 minutes before the end when Japanese Kamui Kobayashi crawled into the pit at the wheel of the Toyota No 7 nearly out of fuel. But he was given a great chance to sample the sweet taste of victory once more when he secured a deal with Toyota to compete in the 24 Hours of Le Mans.
As the clock ticked past 24 hours, the relief was visible on all the faces of the Toyota crew in the pit and the winning drivers as they completed a victory lap with Alonso and Buemi sitting on the vehicle as Nakajima, who completed the last stint, drove.
Jenson Button's Le Mans debut was hard, his SMP Racing BR1 losing two hours with a technical problem early on. Victory was theirs to lose - but Toyota have been burnt before, losing victory on the final lap two years ago.
Trump a factor in South Carolina races as 5 states hold primaries
Mark Meadows issued a statement shortly after Trump's tweet that reaffirmed he was "very supportive" of Sanford's re-election bid. The hosts were discussing Donald Trump critic Mark Sanford's defeat Tuesday in South Carolina's first congressional district.