The McLaren F1 driver had been linked to a drive in the French classic for several months, as he chases his dream of winning motor racing's unofficial ‘Triple Crown'.
A deal has now been reached for Alonso to race for Toyota in as many WEC rounds as possible.
McLaren and Alonso have agreed that his priority remains F1, so he will miss Toyota's home WEC race at Fuji on October 21 because it clashes with the United States Grand Prix.
Alonso made his debut in the Indianapolis 500 last year, skipping the Monaco GP to do so, and challenged for the win before retiring with engine failure.
He said this is the next step in his goal as he has “never been shy” about adding Indy and Le Mans to his Monaco Grand Prix success.
“We tried for Indy last year, came close, but just missed out,” he said.
“This year, I have the chance thanks to McLaren to race for the win at Le Mans.
“It is a big challenge much can go wrong, but I am ready, prepared and looking forward to the fight.
“My deal to race in WEC was only made possible through the good understanding and strong relationship I have with McLaren, and I'm very happy that they listened and understood what this means to me.
“In no way will this challenge take away from my main target of Formula 1 with McLaren.
“In 2018, my aim is to be competitive at every grand prix, and I feel sure that we are closer to achieving that.”
McLaren executive director Zak Brown said his team had no hesitation in giving Alonso permission to race elsewhere, because it felt a boost to his motivation would be beneficial to its grand prix hopes.
“Everybody within our organisation appreciates that a motivated, hungry and happy world-class driver such as Fernando is a formidable asset for any team in F1,” said Brown.
“Last year, we came to the joint decision to go racing with Fernando at the Indy 500 rather than at the Monaco Grand Prix.
“But we've always said that we would consider each opportunity on a case-by-case basis, and we both know that, in 2018, our core priority is success in Formula 1.
“Like Fernando, at McLaren we're racers at heart, and our team is built on a brave heritage of competing and succeeding in different forms of the sport.
“Equally important is the confidence that nothing detracts from our number one goal of Formula 1.
“After proper evaluation, we are satisfied that this campaign does not do that, and that McLaren's best interests prevail.”
The WEC's coming superseason also includes three races in 2019, but whether Alonso continues with Toyota beyond the end of the calendar year is to be decided.