Fernando Alonso is to take part in the Le Mans 24 Hours and all but one of the World Endurance Championship races with Toyota this year.
McLaren revealed the news, previously reported by BBC Sport in November, saying Alonso’s Formula 1 commitments remained “their shared top priority”.
The statement said Alonso would miss the Japanese WEC round as it clashes with the US Grand Prix on 21 October.
Alonso, 36, said he hoped to realise his ambition of winning Le Mans.
The two-time F1 champion has set himself the target of winning motorsport’s so-called ‘triple crown’ of Monaco Grand Prix, which he has won twice, Le Mans and the Indianapolis 500. Only Graham Hill has achieved the feat so far.
He competed at Indy in 2017 and was running competitively when his engine failed in the closing stages of the race.
Alonso said: “We tried for Indy last year, came close, but just missed out.
“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: “It’s no secret that Fernando has wanted to contest the Le Mans 24 Hours. I think 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.
“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.”