Islam Slimani's second-half header earned Algeria a 1-1 draw with Russia in their pivotal Group H encounter and a place in the last 16 of the World Cup.
For long periods it appeared as though it would be Fabio Capello's side toasting a place in the second round, with Aleksandr Kokorin nodding them into an early lead.
It was, however, to be Algeria who wrote their own piece of history by reaching the knockout stage - where they will face Germany in Porto Alegre on Friday - for the very first time.
They headed into a midweek meeting with Russia knowing that a point would likely be enough to see them through, but they fell behind inside six minutes as Dmitri Kombarov whipped over a pinpoint cross for Kokorin to plant a powerful header into the top corner.
Algeria toiled for the remainder of the first half, but snatched a priceless leveller on the hour mark as Russia goalkeeper Igor Akinfeev flapped at a Yacine Brahimi free-kick and Slimani rose highest at the back post to nod into an empty net.
It did not look good for Algeria, impressive conquerors of South Korea last time out, when they fell behind inside six minutes at the Arena da Baixada.
Kombarov advanced down the left and sent in an inviting cross which Kokorin powered past Rais Mbolhi from 12 yards.
Algeria should have had a penalty when Slimani was tugged in the box by Aleksei Kozlov, but referee Cuneyt Cakir did not penalise the offence.
Oleg Shatov came close to doubling Russia's lead in the 26th minute, with a dipping shot from more than 20 yards narrowly off target, before Slimani brought a good save out of Akinfeev from 10 yards at the other end three minutes later.
Yacine Brahimi tried his luck with a low drive in the 35th minute, but it did not carry enough power to seriously challenge Akinfeev, who gathered comfortably.
Mbolhi was the first goalkeeper called into action in the second half, making an excellent stop to deny Aleksandr Samedov within two minutes of the restart.
Both Russian full-backs, Kombarov and Kozlov, picked up bookings within the space of less than three minutes as Algeria threatened down the flanks - and the second free-kick brought about the equaliser.
Akinfeev failed to cut out the resulting free-kick, taken by Brahimi, and Slimani took advantage of space at the back post to head home his second goal of the tournament, from five yards.
Aleksandr Kerzhakov tested Mbolhi with a low drive in the 70th minute, then Kokorin saw a shot blocked soon after as Russia sought the goal they needed to continue their interest in the tournament.
However, the 2018 hosts created little in the closing stages of the contest and when Cakir blew his whistle, they exited the competition while Algeria were looking forward to a match against Germany - who they beat in the group stages of the 1982 World Cup.