James Rodriguez scored a penalty in second-half stoppage time to give Colombia a 3-2 win over Costa Rica on Tuesday and a place in the Under-20 World Cup quarterfinals.

Luis Muriel gave Colombia a 1-0 lead in the 56th minute, but Costa Rica came back with goals in the 63rd by John Ruiz and in the 65th by Mynor Escoe to take the lead and threaten the hosts with a surprise elimination.

However Colombia's Pedro Franco equalized with a 79th-minute header before Rodriguez's dramatic late winner.

Colombia has won all four of its matches in the tournament and looks a genuine title chance, thriving on wild support at home and the edge of playing at an altitude of 2,600 meters (8,600 feet) in Bogota.

Colombia's quarterfinal opponent will be Mexico, which beat Cameroon in a penalty shootout after a 1-1 draw on Tuesday.

A tight match was settled just seconds into stoppage time when English referee Mark Clattenburg awarded a penalty after Ariel Soto pulled down Colombia's Duvan Zapata. Rodriguez stepped up and rammed home the penalty for his third goal of the tournament.

Muriel, of Italian club Udinese, gave Colombia the lead when he chased the ball into the area as Costa Rica keeper Aaron Cruz came 10 meters (yards) off his line to meet him. Muriel won the chase and chipped the ball home for his fourth goal of the tournament.

Costa Rica equalized in the 63rd when Ruiz ran on to a long ball and drilled a 15-meter (yard) shot under Colombia keeper Cristian Bonilla. Two minutes later, Mynor Escoe barged through several Colombia defenders and slotted home a shot from 18 meter (yards).

Costa Rica seemed headed to victory before Pedro Franco headed home in a cross from Rodriguez, who maneuvered on the wing before finding an opening to put the ball into the area.

The first half was a standoff with Colombia having more possession but Costa Rica looking more menacing, particularly on the counterattack.

Both teams hit the crossbar once.

Costa Rica's Joel Campbell banged it off the woodwork in the 23rd minute on a 30-meter (yard) free kick. Campbell also threatened on another free kick, as did teammate Juan Golobio.

Colombia's Jose Valencia hit the crossbar in the 35th with a long shot that sailed over the fingertips of Costa Rica keeper Cruz. Michael Ortega also came close with Rodriguez and Muriel being held in check.