Team DSM's Alberto Dainese (3rd L) edges the sprint on stage 17 ahead of Jonathan Milan (R) and Michael Matthews (2nd R)

Caorle (Italy) (AFP) - Italian rider Alberto Dainese edged the sprint on Wednesday’s stage 17 of the Giro d’Italia as Geraint Thomas finished in the pack to keep the leader’s pink jersey.

Mark Cavendish, who announced on Tuesday that he would be retiring at the end of the season, made an error a kilometre out from the finish of the flat 197km ride from Pergine Valsugana.

The 38-year-old lost his lead-in man and finished well back, most probably ending his record of winning a stage at every Giro he has ridden unless he can survive the mountains over the next three days and take Sunday’s finale in Rome.

Dainese’s DSM team led the peloton around the last bend with 400m to go but it was Michael Matthews (Jayco-AlUla) who then came to the front.

Dainese, 25, caught the Australian while Jonathan Milan (Bahrain Victorious) put in a fierce burst that meant the three of them crossed the line together.

“Today we rode an insane final with the boys and Marius (Mayrhofer) did a super job and then Niklas (Markl) to finish it off,” said an ecstatic Dainese, who also won a stage in the 2022 edition.

“When he swung off I was a bit overtaken by the guys on the left so I had to squeeze to try and catch Matthews.

“The last metres I was digging so deep, I was really on the limit and I saw Jonathan Milan coming.

“I couldn’t really throw my bike but it’s nice to get a few centimetres of my wheel ahead of Johnny to get the win.”

Forty-eight riders have withdrawn already from the Giro, many through Covid and other viruses and Dainese admitted he has also been under the weather.

“I’ve been quite sick with stomach issues and my breathing the last few days,” he said.

“Today was the first day I was feeling okay, like at 80 percent, so to win like this after such a struggle is insane and I’m super-happy.”

Thomas (Ineos Grenadiers) kept out of trouble and, with four stages to come, holds an 18-second lead over Joao Almeida (UAE Team Emirates) with Primoz Roglic (Jumbo Visma) a further nine seconds back.

“The day was nothing like what we had experienced before,” said Welshman Thomas, who will celebrate his 37th birthday in the pink jersey on Thursday.

“It was nice and warm at the end, which is good. It was perfect to keep our strength up before the three days ahead of us.”

Thursday’s stage 18 takes the riders back into the mountains for what may well be the decisive day. They face a punishing 161km ride from Oderzo that takes in a series of intermediate climbs to Val di Zoldo.