El Tri squeezed into the final four thanks in large part to goalkeeper Guillermo Ochoa, who made a brilliant save deep into extra time and crucially denied Keysher Fuller in the subsequent penalty shoot-out.
The favourites might have avoided the fright had Panamanian match official John Pitti not awarded Costa Rica a second-half spot-kick for a seemingly fair Luis Rodriguez challenge on Joel Campbell that appeared to occur outside the box.
Bryan Ruiz converted to cancel out Raul Jimenez's opener and the additional 30 minutes proved costly for Mexico as head coach Martino was shown a yellow card for remonstrating with the fourth official, his second of the tournament prompting a touchline ban for the semi-final date with unheralded Haiti.
"The refereeing was bad," Martino said.
"It's impossible, with the technology that exists today and with VAR in Mexico and with VAR in the United States, that this tournament be played without VAR.
"I'm out of the next game and this referee could officiate the final of the tournament.
"I don't think it's fair that a referee from Panama, who [are still in the tournament], leads this game."
Mexico are now two wins away from reclaiming the Gold Cup crown they conceded to the United States four years ago and Martino is confident his squad will be fresh enough for the clash with Haiti, who came from two goals down to knock out Canada.
"I'm very happy with what we have done," the Argentine said.
"The medical team told me there are issues with cramps due to the 120 minutes the players had to run.
"We have three days until the semi-final with a trip in between, but I think it will be possible to play on Wednesday without problem."
The remaining quarter-final ties take place on Sunday as Jamaica meet Panama before the USMNT tackle the tournament's surprise packages Curacao, with the winners of those two ties then meeting in the semi-finals.