Dutch rider Koen Bouwman won a sprint finish in the mountains for stage 19 of the Giro d'Italia at Santuario di Castelmonte on Friday as Richard Carapaz held the leader's pink jersey.

Ecuador's 2019 Giro winner Carapaz holds a slim three-second advantage on Australian Jai Hindley two days before the race finishes with a time-trial in Verona.

Bouwman negotiated the jostling on a sharp final bend to beat his four breakaway companions for his second stage win after Potenza in southern Italy two weeks ago.

Quick Step's Mauro Schmid of Switzerland was just behind with Italian Alessandro Tonelli of Bardiani three seconds off the pace.

"After I won one stage I said anything else would be a bonus," said Jumbo-Visma's Bouwman who is assured of the top climber's blue jersey providing he finishes the race.

"Today I rode for the Maglia Azzurra and I'm glad I secured it.

"I knew about the last corner but I didn't expect it to be that sharp.

"I had to break but it's great that I was in the best position there. That gave me the win. I'm delighted."

Carapaz survived the setback of losing his key mountain lieutenant Richie Porte early in the 178km stage from Marano Lagunare which included four climbs and crossed into neighbouring Slovenia.

Ineos Grenadiers rider Porte was dropped from the peloton on the first climb of the day, the third-category Villanova Grotte, after 70km of racing. Organisers later confirmed the 37-year-old Australian had withdrawn from the Giro.

"It's been a pretty hard stage," said Carapaz.

"It's a pity that we lost Richie Porte early in the race but the team has done a great job and Pavel Sivakov is in a great shape.

"All top three riders, we're together. It's fine with me. Whatever happens tomorrow will be fine with me too."

A 12-man breakaway approached the main climb of the day, the Kolovrat over 10.3 km and with a 9.2 percent gradient, with more than nine minutes on the peloton.

The four survivors only lost a little over a minute on this climb near Caporetto, the site of an historic defeat for the Italians in the First World War.

Neither Carapaz nor Hindley tried to pull ahead in the final climb having made several attempts earlier along with Spaniard Mikel Landa, third in the standings.

The Giro will go down to the wire with Saturday's stage in the Dolomites now looking crucial to the outcome.

RTL

Ecuador's Richard Carapaz (L) holds his lead in the Giro d'Italia on Australian rider Jai Hindley (C) / © AFP

The 20th stage, the last in the mountains, includes three great climbs -- the San Pellegrino, the Pordoi for the highest point of this year's race at 2,239 meters above sea level concluding at the Fedaia, with a spectacular steep climb in the last 5400 metres.

Sunday's final stage is a 17.4km individual time-trial into Verona where Ecuadorian Carapaz claimed overall victory three years ago.