Carapaz comfortably held off two-time champion Vincenzo Nibali in the 194km ride from Feltre as the 20th stage was won by Spaniard Pello Bilbao (Astana), his second victory of the race.
It was a chaotic ride throughout, with Colombian Miguel Angel Lopez, who holds the white jersey for the best young rider, lashing out at a fan after tangling with him in the final few kilometres.
The Astana rider escaped possible exclusion, the race jury foregoing punishment for an incident Lopez said was a human reaction in the circumstances.
"It was a bad situation...I am very sad because of the bad security level of the riders during the race," he said in a team statement. "Today we had a plan to fight for the stage and to improve my position in the general classification.
"It is a pity I lost my chances today because this incident happened, but, unfortunately, this kind of situations happen regular and this is not good. I’d like to see more respect to the riders, who are doing their best during a cycling race.
"I am sorry for my emotions, but in the rush of the race, especially, in the final of the queen stage it is hard to control it.
Lopez was one of the attackers of the day along with Nibali, the GC remaining the same except for Roglic, who was dropped in the final climb up to Monte Avena. The Slovenian was also gifted a 10 second time penalty after unsolicited assistance from a spectator.
As a result, the Jumbo-Visma rider slipped from third to fourth overall to the benefit of Spain's Mikel Landa, Carapaz's lieutenant at Movistar.
“How am I feeling at the moment? Tired”, Roglic said. “We will see tomorrow, after the time trial in Verona, wether I had the legs to finish on the podium today. I gave 110 percent and kept fighting until the finish. I cannot blame myself.
"This was a very tough queen stage. About the spectators I can only say that it is impossible to keep everything and everyone under control. There were many Slovenian supporters today who came to encourage me. I am very grateful for that.”
Sensing Roglic's weakness and trying to make the most of his last chance of unsettling Carapaz, Nibali, one of two active riders with titles in all three grand tours, gave everything in the last four kilometres.
But the duo of Carapaz and Landa proved too hard to shake as Bilbao sprinted to victory on the day ahead of Landa.
"We've tried to win the stage with Mikel Landa as well as myself to retain the Maglia Rosa but we've missed out by very little," said Carapaz.
"However, we're happy with how it went today. I believe 1:54 over Nibali is enough, although anything can happen in a final time trial."