Algeria moved up to second in World Cup Group H as they overcame South Korea in a six-goal thriller in Porto Alegre.
Islam Slimani ran onto a long ball to flick in the first and a Rafick Halliche header put Algeria 2-0 up.
Abdelmoumene Djabou sidefooted in a third, before Song Heung-min’s low shot pulled one back as South Korea rallied.
Yacine Brahimi added Algeria’s fourth and, despite Koo Ja-cheol scoring a second for Korea, Algeria held on for their first World Cup win since 1982.
Algeria, narrowly beaten by group leaders Belgium in their opening game, knew a second defeat would end their hopes of getting out of the group stage for the first time. They responded in emphatic fashion, becoming the first African team to score four goals in a World Cup game.
A win for the Desert Foxes against Russia will now secure a last-16 spot, and a draw could be enough if South Korea fail to beat Belgium.
Algeria coach Vahid Halilhodzic made five changes from the opening defeat by Belgium and his reshuffle had the desired impact.
Sofiane Feghouli had a strong shout for a penalty turned down when he appeared to have been tripped by Kim Young-gwon before the ball fell for Brahimi to hook over.
Slimani then found space at the far post only to head wide and also badly mistimed a first-time shot from six yards as he met an inviting cross from Aissa Mandi.
But the Portugal-based striker, who was his side’s top scorer in qualifying, did not take long to atone as he outpaced two defenders to get to a long Carl Medjani pass and flick the ball past on-rushing keeper Jung Sung-ryong.
Defender Halliche extended the lead two minutes later with his second goal for his country, a thumping header from an Djabou corner.
And Djabou turned from provider to goalscorer when Slimani slipped a ball across for him to sidefoot home.
South Korea had not managed a shot on target in the first half but pulled a goal back shortly after the break – a mistake from Madjid Bougherra allowing Song to send a shot through the legs of keeper Rais Mbohli.
It was now Algeria’s turn to be penned back and they survived a further scare when Ki Sung-yueng had a long range shot palmed over by Mbohli.
However, Brahimi restored his side’s three-goal advantage when he played a one-two with Feghouli before slotting past Jung.
But a much-improved South Korea were not finished, and after the Desert Foxes failed to clear their lines, Lee Keun-ho played the ball across the box for Koo to slot in, before a tiring Algeria managed to regroup and close out the win.
Algeria coach Vahid Halilhodzic:
“We played an almost perfect first period.
“We played very well, very effectively and then it went down a little bit – maybe it was psychological, maybe it was physical – we will have to talk about this.
“But I think that this was a real feat this afternoon and I would like to congratulate my players.”
South Korea coach Hong Myung-bo:
“In the stadium, there were a lot of Korean fans and I would like to apologise to them.
“We have one game left and I would just like to promise that we will do our best for the next match.”