Mexico ended a four-match losing streak with a come-from-behind 3-2 win over Costa Rica in a friendly on Thursday.

Raul Jimenez's penalty proved the match-winner at the Estadio Universitario de Nuevo Leon after the hosts had twice come from behind, Victor Guzman and Henry Martin cancelling out goals from Joel Campbell and Bryan Ruiz.

Campbell opened the scoring just before the half-hour mark, the forward heading in a Bryan Oviedo cross at the back post.

But, the host responded four minutes later, a fine team move ending with Guzman wonderfully side-footing a volley into the top corner from a Jose van Rankin cross.

READ: United States 2 Colombia 4: James nets stunner in six-goal thriller

Costa Rica – which announced Gustavo Matosas as its next coach on Tuesday – restored its lead just before half-time through Ruiz, who placed a penalty into the bottom corner after Van Rankin gave away a spot-kick for a handball in the area.

Ruiz's goal was his 25th for the national team, moving him into outright fifth on Costa Rica's all-time list. Introduced at half-time, Martin scored his first international goal to draw Mexico level once more in the 56th minute, heading in a Jurgen Damm cross.

Martin continued to have a major impact, fouled from a set-piece to give Jimenez a chance from the penalty spot and the forward made no mistake as Mexico claimed a first win since the World Cup and extended Costa Rica's run without a victory to eight matches.