(CNN) -- Alan Kardec scored a spectacular second-half winner for Brazil against Costa Rica to set up a replay of the 1993 Under-20 World Cup final against Ghana in Egypt.
Costa Rica midfielder David Guzman, left, battles for the ball with Brazil captain Giuliano.
Four-time champions Brazil edged a 1-0 victory against underdogs Los Ticos in Cairo after the Black Satellites qualified for the final for the third time with a 3-2 victory against suspension-hit Hungary in the first semi.
Striker Kardec's 67th-minute goal, his fourth of the tournament, lit up an otherwise uninspiring match as he crashed home a superb volley from a tight angle after substitute Bertucci's left-wing cross bounced to the far post.
Costa Rica had lost their opening game of the tournament to Brazil by a morale-sapping 5-0, but bounced back to reach the last four, beating hosts Egypt and the United Arab Emirates in the previous rounds.
The Central Americans came closest to scoring in the first half as David Guzman's 25-yard free-kick forced a fine save from Brazil goalkeeper Rafael.
However, the South Americans' dominance of possession -- they had an incredible 70 percent of the play -- finally told, with players lining up to take potshots at Costa Rica's goal.
But Los Ticos held on bravely, and even sent goalkeeper Esteban Alvarado to the other end of the pitch for three late corners, but the lack of quality in crucial areas was telling.
Ghana will be seeking to win the tournament for the first time on Friday, having lost to Brazil in the 1993 final and to Argentina in 2001.
The Africans looked lethal in attack against a Hungary side missing three key players following the dramatic 3-2 victory over Italy in the quarterfinals, but suffered from defensive lapses.
Dominic Adiyiah netted twice to give Ghana a 2-0 halftime lead before Marco Futacs pulled one back, but Abeiku Quansah crashed a spectacular late goal to make it 3-1 and substitute Adam Balajti set up a tense finish.
Striker Adiyiah netted the opener from close range in the ninth minute after Andre Ayew pounced on Adam Presinger's poor back-pass and rounded goalkeeper Peter Gulacsi.
He then scored a tournament-leading eighth goal in the 31st minute with a powerful header from Samuel Inkoom's cross.
Balazs Megyeri hit the post for Hungary in the second half before fellow substitute Marko Futacs reduced the deficit in the 73rd minute after a pass into the penalty area from Andras Simon.
Roland Varga and Janos Szabo both squandered golden chances to level, the latter from a simple header, and Ghana made the most of their escapes when Quansah crashed in a shot off the underside of the crossbar in the 81st minute.
David Addy's lapse allowed Balajti to comfortably sidefoot home just three minutes later, but it was Ghana who looked most likely to score again as Emmanuel Agyemang-Badu smashed a fierce long-range shot against the bar in time added on.