Primož Roglič has taken the general classification lead in the Giro d'Italia ©Getty Images

Primož Roglič inflicted heartbreak on Britain's Geraint Thomas by snatching the pink jersey after the penultimate stage of the Giro d'Italia.

The Slovenian overcame technical difficulties, as his chain came off just 10 minutes from the end, to triumph in the 18.6-kilometres time trial from Tarvisio to Monte Lussari after 44min 23sec.

The result means that Roglič turned a 26-second deficit into a 14-second lead in the general classification.

It is a massive dent in the chances of 37-year-old Thomas winning the race for the first time as tomorrow's finals stage is seen as a largely processional affair.

"It feels amazing.

"It's incredible.

"My chain dropped but I put it back.

"I could have lost everything but it's part of racing.

"The crowd gave me some extra watts and I was enjoying the atmosphere and the energy around the event.

"One day to go.

"The course is a bit technical.

"It's not over until it's over but it looks good."

Thomas appeared faster on the flat first section of the stage, but a slower bike change plus the decision to switch his helmet cost him precious time.

Roglič then clearly outpaced his rival on the final climb and was eating into the lead before the chain malfunction which forced him to dismount to fix it.

However, the accident seemed to spur him on further to extend the distance between the chasing pack.

"I could feel my legs going about a K and a half from the top of that climb," said Thomas.

"I don't want to sound like I’m making excuses, but I just didn't feel like I had that real grunt.

"I guess it is nice to lose by that much rather than a second or two, because that would be worse.

"To be honest Primož deserves that.

"He had a mechanical as well and still put 40 seconds into me."

Portugal's João Almeida made up the top three in the stage, crossing the line two seconds after Thomas.

Tomorrow sees the conclusion of the Giro d'Italia with a flat 126km stage comprised of six laps of a circuit in Rome.