The result means that the Central Americans finish second in the group, setting up a quarterfinal encounter against Group B champion Cuba on Tuesday. The U.S. will play the winner of Canada-Nicaragua, who are scheduled to meet later in the evening at the same venue.
In a game marked with an overabundance of fouls (49) and yellow cards (6), the first half produced little in the way of meaningful action. Both teams appeared content not to concede a goal, despite the fact that Costa Rica needed a win to capture the group.
The second half started much the same way the first ended, until Villarreal sparked proceedings to life in the 63rd minute. Luis Gil delivered a corner kick just beyond the Ticos' six-yard box and the unmarked LA Galaxy forward soared high to snap a header home.
Now requiring two unanswered goals to snatch victory, the Costa Ricans immediately increased the speed of their attack, displaying renewed urgency.
In the 66th minute, Mayron George fended off U.S. defender Caleb Stanko to shoot hard, but directly at goalkeeper Cody Cropper.
Costa Rica's best chance of the match came eight minutes later, when Giovannie Cantillano gained possession in the American box, spun to elude a defender, only to see his effort from eight-yards crash off the crossbar.
With time running out, Cropper was forced to make another save after Fabian Garitza did some neat work inside the penalty area to free himself for a shot.
While Costa Rica's Under-20 Championship itinerary is set, the U.S. will await the identity of its next opponent.