Oribe Peralta and Giancarlo Gonzalez contest a header

Oribe Peralta had four or five good chances to score for Mexico -- all of which he missed -- but it was the one he set up that mattered most. 

Peralta drew a dubious penalty in the 120th minute, and Andres Guardado converted from the spot to give Mexico a 1-0 win over Costa Rica in the quarterfinals of the 2015 CONCACAF Gold Cup. El Tri advanced to the semifinals, where they will take on Panama on Wednesday in Atlanta.

Peralta was back in the starting lineup after being dropped in Mexico's final group-stage game in favor of recent LA Galaxy signing Giovani Dos Santos. But Dos Santos, who came off injured in that match, was relegated to the bench for the quarterfinal and did not see the field.

In an exciting, back-and-forth clash in front of more than 80,000 fans at MetLife Stadium, Peralta was the main dangerman for Mexico all night. He had two great chances to break the deadlock: In the 45th minute, after collecting a pass from Carlos Vela and cutting around a defender, but he was unable to finish. In the 50th minute, he hit the post with a shot that beat Ticos goalkeeper Esteban to the right side.

For Costa Rica, Joel Campbell was a constant threat to send the Ticos to the semis for the first time since 2009. The Arsenal forward's pace and tenacity nearly led to a goal when he chased down a ball on the right side, performed a sliding pirhouette, and sent a long, looping shot/cross toward the far post that forced Mexican goalkeeper Memo Ochoa to punch it wide. Campbell then sent a cross into Johan Vanegas in the 35th minute, but the Alajuelense winger fired his shot wide.    

After 90 minutes of scoreless play, the match went into added extratime, and Mexico took over. They dominated possession and continuously created threatening chances.

Finally, as the match seemed destined for a penalty shootout, Peralta was nudged by New York Red Bulls defender Roy Miller as he atttempted to connect on a close-range header. Replays indicated there was minimal contact -- but contact nevertheless -- and referee Walter Lopez pointed to the spot.

With barely seconds to play, Guardado stroked his penalty home, igniting pandemonium and keeping Mexico's hopes of recapturing the Gold Cup from the United States and forcing a playoff for CONCACAF's Confederations Cup berth.

Mexico will next face Panama, who beat Trinidad and Tobago in penalties earlier in the day, on Wednesday at 9 pm ET, at the Georgia Dome in Atlanta.