Italian motorcycling legend Valentino Rossi has undergone successful surgery after breaking his leg in a training crash and will have to rest for 40 days, doctors confirmed on Friday.

If the 38-year-old is sidelined for two months he would miss the next two MotoGP races in San Marino and Spain but could possibly return in Japan on October 15.

“It will depend a lot on him but I think that he will have to rest at least 40 days,” said Dr. Raffaele Pascarella, who carried out the surgery.

“However, he has already said he wants to return as soon as possible.”

The nine-time world champion in all categories was on board an endurance bike when the accident happened and was first transferred to hospital at Urbino, in eastern Italy, and later underwent surgery in Ancona.

“Valentino Rossi had a successful operation on the displaced fractures of the tibia and fibula of his right leg,” his Yahama team said in a statement.

“The surgery went well. This morning, when I woke up, I felt already good,” Rossi said.

He thanked Pascarella and added: “I’m very sorry for the incident. Now I want to be back on my bike as soon as possible. I will do my best to make it happen!”

Doctors said on Friday that Rossi would remain in hospital for three to four days and would then begin physiotherapy but would have to rest for a further 40 days.

Dr Pascarella added that a nail inserted to stabilise the rider’s leg would remain in place for 18 months.

The nine-time world champion in all categories is lying fourth in this season’s MotoGP standings after 12 of 18 races.

This is the second time Rossi has crashed this year. In May he was treated in hospital for chest and stomach injuries after a motocross training spill.

Rossi briefly led the 2017 MotoGP championship after three successive podium finishes in Qatar, Argentina and the United States.

After dropping off the pace he reignited his dream of an eighth title in the top division with victory in the Dutch Grand Prix at the end of June.

San Marino hosts the next race on September 10 with Rossi 26 points behind leader Andrea Dovizioso.

Rossi’s contract with Yamaha runs until the end of the 2018 season, but an extension until the end of 2019 had been on the table for the past few months.