Ecuador will face South Korea in the semi-finals of the FIFA 2019 Under-20 World Cup.
South Korea beat Senegal 3-2 via a shootout after an extraordinary match which ended 3-3 after extra time, in a controversial game featuring two penalties and two last-second equalisers.
Cavin Diagne handed the African side the lead on 37 minutes with a powerful finish as Lee Kang-in came closest for Korea in the first half with a free-kick.
Kang-in did draw Korea level just after the hour from the penalty spot after the video assistant referee (VAR) intervened following a Senegal foul, slotting low to goalkeeper Dialy Ndiaye's right.
There was another VAR intervention 10 minutes later after a handball by Lee Gwang-yeon, which after several minutes of review saw a penalty awarded to Senegal.
Metz striker Ibrahima Niane scored from the spot, and they looked to be heading through until Lee Ji-sol dramatically levelled the scores in the eighth minute of injury time.
The comeback appeared complete in the 96th minute as Kang-in played a perfect through ball for Cho Young-wook to finish past Ndiaye to seemingly send the Koreans through.
Amadou Ciss had other ideas, however.
On 120 minutes and five seconds, the superb work of Mamadou Danfa saw him break the Korean defence before pulling back to Ciss, who drove his shot past Lee Gwang-yeon to send the match to a shootout.
There, Korea missed their first two penalties, only for Mamadou Mbow to screw wide and Dia Ndiaye to have his effort saved by Gwang-yeon to make it 2-2 after four efforts each.
Dialy Ndiaye appeared to have saved the fifth Korean kick by Oh Se-hun, but a retake was ordered and scored – before Cavin missed to end one of the most extraordinary games in any recent FIFA competition.
Earlier, South American champions Ecuador overcame United States 2-1 in a clash of continental giants.
Jose Cifuentes set the tone in Gdynia with a first-half screamer from 25 yards, his right-footed strike leaving American goalkeeper David Ochoa with no chance.
The US equalised in the 36th minute through Paris Saint-Germain forward Tim Weah, son of former world player of the year George.
Weah junior, who spent the second half of last season on loan at Scottish champions Celtic, volleyed in his second goal in Poland from close range after Alex Mendez's corner.
Ecuador found the winner just before halftime through the unlikely source of Jhon Espinoza, the defender making a bursting run from the back and slotting in from Leonardo Campana's pass to the centre.
Ecuador and Korea meet on Tuesday night in Lublin, the winner facing Italy or Ukraine in the final.