Fernando Alonso will test McLaren's 2019 Formula 1 car as part of a new role as team "ambassador", following his decision not to race in F1 this season.

The two-time world champion rejoined McLaren in 2015 but opted to step away from grand prix racing for 2019 following years of uncompetitive machinery, and an urge to compete elsewhere.

Alonso had already been confirmed to race for McLaren in this year's Indianapolis 500, but his much-speculated involvement in the F1 team's testing programme has now been firmed up as well.

He will drive at "selected tests to support the development of MCL34 and MCL35 for 2020", McLaren has confirmed.

McLaren will have four official test days during the season. Two of which must be completed by rookie drivers who have not competed in more than two grands prix, but Alonso would be free to drive on either of the other two days.

The team says Alonso will also advise the F1 team's drivers and engineers as part of a "wide-ranging" ambassadorial agreement.

"I said before I stopped racing in Formula 1 last year that I see myself with McLaren for a long time to come, so I am delighted at this new role and the ability to stay closely involved with the team I feel is my spiritual home," said Alonso.

"We have the Indianapolis 500 in May of course, which I am looking forward to immensely, but this is just the beginning of many things we can do together.

"I am particularly passionate about nurturing young talent, whether that's with my own team or helping the new generation of Formula 1 drivers at McLaren unlock their true potential.

"This is important to both the team and myself, so will be an especially rewarding part of my role."

Alonso has a busy race programme alongside his McLaren F1 role and bid to win the Indy 500 and complete motorsport's unofficial triple crown.

He and his Toyota teammates are leading the World Endurance Championship points, having won the Le Mans 24 Hours last year.

Alonso also took victory in the Daytona 24 Hours last month alongside Wayne Taylor Racing teammates Kamui Kobayashi, Renger van der Zande and Jordan Taylor.

He joins double world champion Mika Hakkinen as an official McLaren ambassador.

"For any race team, having someone of Fernando's class on hand to provide support through his experience is of huge value," said McLaren Racing CEO Zak Brown.

"His insights and perspective will be welcomed by both our drivers and engineers alike, while his stature and character remain highly appealing to our partners and fans."