Despite their best efforts, the two nations couldn't break the deadlock in extra time.
Raul Jimenez opened the scoring with a sharp turn and finish in the 44th minute, capping a crazy sequence of end-to-end football.
But the night changed completely when referee John Pitti awarded Costa Rica a penalty in the 50th minute for a foul on the streaking Joel Campbell. Replays showed Campbell was clipped just outside the area, but without video assistant referees at the Gold Cup, the call on the field stood. Bryan Ruiz converted with ease.
Both sides continued to gun for goal on the counterattack, and both goalkeepers made excellent reaction saves to send the contest into extra time.
Ochoa eventually won the battle between the pipes. His acrobatics denied Costa Rica's Keysher Fuller in sudden-death penalties, and he and his teammates wheeled away in celebration.