Cote d'Ivoire fought back from two goals down to draw 2-2 with Algeria in an Africa Cup of Nations Group D dead rubber in Rustenburg.
Eliminated Algeria looked set to finish the tournament with an upset victory over already-qualified Cote d'Ivoire thanks to second-half goals from substitute Sofiane Feghouli and El Arbi Soudani.
However, Cote d'Ivoire, which might have been 3-0 down with Ryad Boudebouz missing an early penalty for Algeria, battled back with two goals in three minutes from Didier Drogba and Wilfried Bony to take a point.
The result leaves Cote d'Ivoire top of Group D with seven points and a quarter-final against Nigeria to look forward to, while Algeria heads home with just one point to its credit.
By far the clearest chance for either side in a close-fought first half came in the seventh minute when Algeria was awarded a penalty when Ismael Traore dragged down Soudani after being turned by the Guimaraes forward on the edge of the box.
It provided Algeria with a perfect opportunity to notch its first goal since last October but it was spurned by Ryad Boudebouz as his drilled spot-kick smashed back off the base of the post.
Arguably Cote d'Ivoire's best opening of the first period fell to Salomon Kalou but the Lille forward blazed high over the bar after creating space for a shot inside the area.
Drogba came close with a 25-yard free-kick in the 26th minute but that also failed to trouble Algeria goalkeeper Rais M'Bolhi as the first half finished goalless.
Algeria should have taken the lead straight after the restart but the unmarked Essaid Belkalem could only head straight at Daniel Yeboah.
However, Algeria did not have to wait much longer to go ahead after being awarded a second penalty in the 63rd minute for a handball by Arthur Boka as he attempted to block a cross.
Feghouli, who just moments before had replaced Boudebouz, took over the spot-kick duties and clinically fired his effort into the top corner.
It was 2-0 seven minutes later after another cross from the right, which this time found Soudani eight yards out and he powered home a header.
That looked to be game over, but last year's tournament runner-up was level within 10 minutes.
Drogba halved the deficit with a fine header from near the penalty spot in the 77th minute and then Bony levelled the scores up with a 25-yard strike which took a huge deflection before beating the wrong-footed M'Bolhi.
Western Sydney Wanderers chairman Lyall Gorman says the club's early experience in the Asian Champions League proves there is no limit to its potential for success.