A superb performance on the final climb saw Dan Martin finish third in stage six of the Giro d'Italia and propel himself right back into contention for the maglia rosa.

Martin began the day in 19th, and more than two minutes down on the pink jersey, but jumped 10 places to sit 47 seconds adrift of new leader Attila Valter.

Stage victory in Ascoli went to Gino Mader, with former Tour de France champions Egan Bernal second ahead of Martin.

Bernal made a statement of intent as the Ineos Grenadiers worked in the wind and rain to soften up rivals before the Colombian attacked on the final climb to take second just ahead of Martin.

Egan Bernal, right, and Dan Martin, sprint for second position on the stage

Groupama-FDJ's Valter, 22, started the day in the best young riders' white jersey but had stated his intent to swap it for pink.

"It's good to make jokes in the morning but to really believe it is another story," he said. "I cannot be more surprised. I knew I had good climbing legs but I had to stick with the best climbers in the world. I could cry I'm so happy, it's just incredible."

Valter now leads Belgian Remco Evenepoel by 11 seconds and Bernal by 16 seconds in the general classification after overnight leader Alessandro De Marchi (Israel Start-Up Nation) finished the stage a whopping 25 minutes in arrears after Ineos Grenadiars blew the race apart with over 70km remaining.

Nicolas Roche is 61st on the genenral classification.

After Mikel Landa and Bernal's team-mate Pavel Sivakov abandoned with broken bones on Wednesday night, Joe Dombrowski and Francois Bidard were also non-starters in the morning as the race continued to count the cost of the crash late on stage five.

"Yesterday was such a sad day with us losing Landa," Mader said. "We decided to ride in his honour today."