VAR intervened to hand Mexico a chance from the penalty spot after a review confirmed a foul on Canada's Donell Henry in the area and Orbelin Pineda converted to put El Tri in front at the break.
Tajon Buchanan drew Canada level early in the second half with an excellent individual effort, picking up a long ball on the left edge of the area, beating his marker and firing past Mexico keeper Alfredo Talavera at his far post to make it 1-1.
Mexico was once again the beneficiary of a video review, with Canada's Mark-Anthony Kaye whistled for a foul on the edge of the box after a VAR check, but Maxime Crepeau saved Carlos Salcedo's spot kick to preserve the draw.
The match was stopped as the second half progressed because of an anti-gay chant from the Mexico fans, but play resumed shortly after.
Herrera pounced on a ball at the top of the area and fired home in stoppage time to hand Tata Martino's side the win and a spot in the final after nearly 13 extra minutes that were very tense between the two teams at times.
The Canadians were without striker Lucas Cavallini and defender Steven Vitoria due to yellow-card accumulation. They were also minus forwards Cyle Larin and Ayo Akinola because of injuries.
Canada was in its first semifinal since 2007 and was looking for its first championship since 2000. The Canadians are the only country beside the U.S. and Mexico to win the Gold Cup.
Mexico will take on the U.S., which beat Qatar in the other semi, in the Gold Cup final in Las Vegas on Sunday. The U.S. beat Mexico in their last meeting in a dramatic finish to win the CONCACAF Nations League.