Valentino Rossi will remain in MotoGP until at least the end of 2020 after signing a two-year contract extension with the factory Yamaha team.
Although the Italian's existing contract was due to expire at the end of 2018, he has been expected to remain with the Japanese manufacturer for some time.
The seven-time premier class champion dropped a clear hint he would continue racing in the most recent Qatar test when he ruled out his VR46 team stepping up to MotoGP before 2021.
Rossi turned 39 last month, meaning he will continue racing until the age of 41 under his new agreement - which would make him the first MotoGP rider to race into his 40s since Colin Edwards in 2014.
He will partner current team-mate Maverick Vinales for the three two seasons, as the Spaniard had already concluded a new agreement to remain with Yamaha until 2020 earlier this year.
"When I signed my last contract with Yamaha, in March 2016, I wondered if that would have been the last contract as a MotoGP rider," said Rossi.
"At that time, I decided that I'd take that decision during the following two years.
"During the last two years I came to the conclusion that I want to continue because racing, being a MotoGP rider, but especially riding my M1, is the thing that makes me feel good.
"I want to thank Yamaha - [team boss] Lin Jarvis and [team manager] Maio Meregalli in particular - for their trust in me, because the challenge is difficult: being competitive until I'm 40 years old!
"I know it's going to be difficult and it requires a lot of effort from my side and a lot of training but I'm ready, I am not lacking in motivation, that's why I'm signing for two more years."
The news Rossi will stay at Yamaha extends a partnership that has yielded a total of 56 MotoGP wins as well as the 2004, '05, '08 and '09 titles.