(CNN) -- Ten-man Germany scored the winning goal in the second minute of injury time to defeat Nigeria 3-2 and secure a quarterfinal showdown with Brazil at the under-20 World Cup in Egypt -- the official FIFA Web site has reported.
Germany's Florian Jungwirth challenges for the ball during the thrilling 3-2 victory over Nigeria in Suez.
Nigeria took the lead in the 51st minute in Suez when Lewis Holtby misplaced pass fell straight to King Osanga, who crossed for Danny Uchechi to head home.
However, Germany levelled straight from kick-off when Bjorn Kopplin's burst through on the left and fired home at the near post with goalkeeper Uche Okafor looking like he expected a cross.
Germany were reduced to 10 men in the 64th minute when Tobias Kempe was shown a straight red card for stamping on the knee of Nurudeen Orelesi and Nigeria took advantage by going ahead again just four minutes later.
Orelesi ran at pace at the German defense before slipping a bobbling ball into the box -- where Rabiu Ibrahim was waiting to fire past goalkeeper Ron-Robert Zieler.
However, Germany refused to lie down and drew level seven minutes later. Kopplin again broke clear on the left and drew the ball back for substitute Mario Vrancic to fire home from eight yards out.
Then, with extra time beckoning, Kopplin broke quickly from a Nigeria corner and ran half the length of the field before slipping the ball past the onrushing Okafor and just inside the post with virtually the last kick of the game.
Meanwhile, Brazil produced their best performance of the tournament to secure their last eight place with a 3-1 victory over fellow-South Americans Uruguay in Port Said.
Brazil dominated the opening exchanges and took a deserved 22nd-minute lead when Paulo Henrique snatched possession before racing forward and releasing Alan Kardec, who beat goalkeeper Martin Rodriguez with a powerful right-foot drive.
They doubled their advantage just two minutes later when full-back Douglas produced some great play on the right before cutting the ball back for Alex Teixeira to fire high into the net.
Brazil's third goal in nine minutes came when Paulo Henrique burst forward from inside his own half and slipped the ball wide to Alex Texeira.
Texeira still had a lot of work to do but made it look easy, jinking past Marcelo Silva on the right-hand edge of the box before curling a delightful left-foot shot into the top corner of the net.
Brazil backed off after that, allowing Uruguay back into the match and Jonathan Urretaviscaya reduced the deficit from close range with nine minutes of the first half remaining.
Both sides missed chances in the second half, but Uruguay's fate was finally sealed when Brazil goalkeeper Rafael saved Abel Hernandez's poor penalty with three minutes remaining.
The other quarterfinalists will be the United Arab Emirates, who came from behind to defeat Venezuela 2-1 in Suez.
The South Americans went ahead in the 12th minute when Carlos Fernandez played a lovely pass with the outside of his boot to find Jonathan Del Valle in space.
The striker played a ball in behind UAE's defence, which Abdulrahman managed to get a hand to, only for it to fall kindly for Jose Rondon, who slotted home his fourth of the tournament.
Venezuela's lead lasted only 10 minutes, as the UAE levelled when Amer Abdulrahaman delivered a free-kick from the right and Mohamed Ahmed rose highest to glance a header into the net.
The winner came with seven minutes remaining when Ahmed Ali squared the ball to strike partner Ahmed Khalil, who squeezed a shot inside the near post.
United Arab Emirates will now face Costa Rica in Cairo for a place in the semifinals.