MONTEGO BAY, Jamaica - John Ruiz scored three goals and Costa Rica defeated El Salvador 3-2 on Friday to give itself the advantage heading into the quarterfinals of the CONCACAF Under-17 Championship.
Both Central American sides already were assured of advancing with Haiti's withdrawal earlier in the week, but the victory gave Costa Rica the Group A title and a match against the Group B runner-up in the knockout round.
El Salvador will play the Group B winner.
Ruiz gave Costa Rica the lead three times, the last with 15 minutes remaining to earn the Ticos their second victory in four days.
Both teams had early opportunities, with Costa Rica's Kelin Angulo shooting just wide from 20 meters in the ninth minute.
Ivan Castro headed just over the crossbar and Gerardo Iraheta shot high and wide off a cross for El Salvador before Costa went ahead in the 16th minute when Ruiz stabbed home from the middle of the penalty area after shaking off a defender.
El Salvador equalized 16 minutes later when an 18-meter attempt from striker Jose Pena was palmed onto the post by Costa Rican goalkeeper Pedro Roman, and Iraheta pounced on the rebound.
Pena continued to threaten the Costa Rican goal, driving a 36th-minute blast that Roman tipped over the crossbar.
Two minutes into first-half injury time, Ruiz restored Costa Rica's lead, getting to Gabriel Leiva's free kick from the right and tucking it inside the near post.
El Salvador equalized a econd time in the 47th, when Iraheta corralled a rebound off a free kick and crossed into the area, where Romel Mejia settled with two touches before scoring.
Costa Rica hit the post twice seconds apart in 73rd minute on shots by Ruiz and Angulo, and finally took a lead it wouldn't relinquish in the 75th.
Ruiz broke into the penalty area and rounded goalkeeper Rolando Morales before finishing for the winner.
El Salvador had two more opportunities late. Mejia hit the crossbar and Roman preserved the victory by thwarting Diego Galdamez in injury time.
Shots on Target