Cairo - Wilfried Zaha scored on his first start at this year's Africa Cup of Nations as Ivory Coast clinched a place in the last 16 with a 4-1 victory over Namibia on Monday.
Max Gradel's precise finish and an own goal by Ryan Nyambe put the 2015 champions in control in Cairo, with late Zaha and Maxwel Cornet efforts wrapping up the win after Joslin Kamatuka had given Namibia hope.
The Ivorians advance as runners-up of Group D behind Morocco, who snatched a last-gasp winner in a 1-0 victory over South Africa that leaves Stuart Baxter's side relying on other results to scrape through as one of four best third-place finishers.
Ivory Coast boss Ibrahim Kamara handed Arsenal target Zaha his first start of the competition in place of Nicolas Pepe at 30 June Stadium, with the Elephants having scored just once in their first two matches.
They were lucky not to fall behind as Peter Shalulile wasted a pair of good chances for Namibia, before Gradel ran on to a wonderful Franck Kessie pass to lift over Lloyd Kazapua to put the Ivorians ahead on 39 minutes.
An unfortunate Nyambe then redirected a speculative Geoffrey Serey Die drive into his own net as Ivory Coast increased their advantage near the hour.
Sloppy defending offered Namibia a lifeline as Kamatuka made it 2-1, but Zaha drilled home a low shot from 15 yards before substitute Cornet smacked home a fourth in the closing stages.
The Ivorians go through to a last 16 encounter with the winners from Group E -- likely Mali or Tunisia -- but South Africa face a nervous 24-hour wait to determine if they will also advance.
Bafana Bafana had also struggled in attack heading into their final group game against Herve Renard's Morocco at Al Salam Stadium.
Percy Tau hammered a shot just wide for South Africa after slick footwork on the edge of the box, while Younes Belhanda volleyed straight at the recalled Ronwen Williams in a quiet first half.
Achraf Hakimi rattled the crossbar with a terrific 25-yard attempt early in the second half, but Morocco won it right at the death as Mbark Boussoufa stabbed home from close range after a free-kick fell into his path.
Having been on course to seal one of four best third-place spots, South Africa will now be counting on Senegal to beat Kenya later Monday while keeping a close eye on Tuesday's results in Group E and F.