The Movistar rider also took over from Jan Polanc (UAE Team Emirates) at the head of the overall classification with an advantage of seven seconds over Primoz Roglic (Jumbo-Visma) with Nibali (Bahrain-Merida) third at one minute and 47 seconds.
Nibali (Bahrain-Merida) was the first to test the strength of the leading bunch with a series of attacks on the Colle San Carlo but he could make none of them stick.
Carapaz then launched off the front and no one could respond to him as he accelerated down the descent and consolidated on the final category three climb of the day.
His 10-second time bonus for winning the stage stopped Roglic reclaiming the maglia rosa.
“We had two cards to play as Mikel Landa and myself are in good form, but today, as Mikel wasn’t going very well towards the end of the stage, it was up to me to catch the right moment and the opportunity," Carapaz said.
"With 25km to go, we realised that the Maglia Rosa was reachable, providing that I rode well downhill before the third category finishing climb that I knew would suit me well.
"The Maglia Rosa has been my dream since I first got interested in cycling at the age of 15, watching the Giro on a cellphone.”
Simon Yates, who recovered after earlier being dropped, tried to chase down Carapaz, finishing strongly in second, a minute and a half behind with Roglic’s group one minute 54 seconds back. Yates moved back into the top 10.
We still have a long way to go," Yates said. "Of course I know it's going to be very difficult now, I am not under any illusion about that, especially with how my rivals are going, but we will see how the next few days go.
"I tried to attack this morning on the very first climb and the big guys wouldn't let me go, I was marked quite heavily there. I was not expecting to be so heavily marked because I'm so far behind now.
"I was still a little bit behind where I wanted to be, where most of the action happened, but I will keep plugging away, keep fighting and go from there."
Overnight leader Polanc cracked on the San Carlo and slipped to seventh overall, more than three minutes down.
Stage 15 is a 232km ride from Ivrea to Como over the Madonna del Ghisallo and Civiglio climbs.
"We tried to make the difference on the hardest climb, the San Carlo but we didn't succeed," Nibali said. "With today's third-place I gained four seconds and even if it was not many it was important to sprint to reward the work of the whole team.
"This morning I had no super sensations but then I was fine and so I tried to make a selection. Tomorrow is another difficult stage and we expect another hard day with the finish line in Como and the same finale of Il Lombardia."