A controversial penalty in the dying stages sent Mexico through to the CONCACAF Gold Cup semi-finals.
Andres Guardado converted a controversial 124th-minute penalty as Mexico prevailed 1-0 against Costa Rica in the CONCACAF Gold Cup quarter-final clash in New Jersey on Sunday.
Mexico had countless opportunities to win the match in regulation time at MetLife Stadium but Miguel Herrera's men were almost left kicking themselves as a shoot-out loomed.
However, referee Walter Lopez awarded a penalty to the Mexicans after Oribe Peralta was felled by substitute Roy Miller under minimal contact in the second minute of stoppage time.
Tireless midfielder Guardado made no mistake from the spot, sending Costa Rica goalkeeper Esteban Alvarado the wrong way.
Mexico will now face Panama in the semi-finals.
Giovani Dos Santos was a notable absentee due to an adductor injury suffered in Mexico's thrilling 4-4 draw against Trinidad and Tobago. He was replaced up front by Peralta.
Costa Rica made two changes to the starting XI that played out a goalless draw with Canada, Joel Campbell and Jose Cubero coming in for Deyver Vega and David Guzman.
Both defences were kept busy from the outset, though neither team could break the deadlock before the break.
One of the best chances of the half fell to Johan Venegas in the 35th minute.
Campbell picked out Venegas with a looping diagonal cross to the back post, but the latter was unable to keep his scooped effort underneath the crossbar.
At the other end, Guardado forced goalkeeper Alvarado into a fine save from distance two minutes later.
Peralta almost opened the scoring on the stroke of half-time as he left his opponent on the floor after cutting inside onto his right foot and firing over the bar.
Peralta continued where he left off six minutes into the second half, side-footing the ball into the bottom of the post.
Costa Rica struggled to keep up with Mexico, who were denied by Alvarado after the shot-stopper pushed substitute Carlos Esquivel's volley onto the crossbar and away for a corner in the 64th minute.
Mexico wasted another great opportunity 10 minutes later, when Carlos Vela beat the offside trap but blasted his shot over as the contest headed for extra time.
Chances were at a premium in extra time, as Mexico had two hopeful penalty appeals waved away by Lopez.
Costa Rica came to life in the second period of additional time, with Campbell weaving his way into the box and almost making the breakthrough as Guillermo Ochoa made a fingertip save at his near post, though the flag was raised for offside.
But with the match seemingly on track for penalties, Mexico benefited from a dubious refereeing decision to advance to the final four.comments