Australian Ben O'Connor made up for a previous second-place finish as he claimed victory on stage 17 of the Giro d'Italia with a solo effort on Madonna di Campiglio.

The NTT Pro Cycling rider had to be content with runner-up to Jan Tratnik on Tuesday, missing out over the final climb.

O'Connor, though, got his stage 17 tactics spot on across the 203km from Bassano del Grappa, which saw four categorised climbs.

The 24-year-old stayed in touch with the 14-riders breakaway which had built a six-minute advantage and then attacked eight kilometres from the finish to power clear and secure what was a morale-boosting first Grand Tour win.

Hermann Pernsteiner was 31 seconds back for Bahrain-McLaren while Belgian Lotto-Soudal racer Thomas De Gendt crossed in third place.

O'Connor was pleased to be able to put the disappointment of the previous stage behind him.

"Yesterday's second place left me feeling pretty bitter," said the Australian, who does not have a contract for 2021 and his NTT team are without a sponsor so could yet be forced to fold.

"Today I was able to bounce back and get this success, it's a dream to get a victory in a Grand Tour."

Portugal's Joao Almeida retained the overall Maglia Rosa lead in the general classification standings.

The Deceuninck-QuickStep rider successfully neutralised an attack from Sunweb to protect his 17-second advantage over Dutchman Wilco Kelderman and Jai Hindley, who is almost three minutes off the pace.

"Today it was a hard day, a lot of climbing, but I had the perfect team with me," Almeida said. "That's one more day in the Maglia Rosa.

"Team Sunweb tried to attack, but I was feeling good. Tomorrow it's another day, I look forward to it."

On Thursday, as the Giro d'Italia will cover 207km from Pinzolo to Laghi di Cancano, on the penultimate mountain stage which features a testing trek up the Passo dello Stelvio.