The 2019 champions got off to a horrible start as Franck Kessie's neat finish and an unmarked Ibrahim Sangare put them 2-0 down at half time.
Arsenal man Nicolas Pepe made it 3-0 shortly after the break before Sofiane Bendebka pulled one back for Algeria.
They could've got a goal back earlier when they were awarded a penalty, however, Riyad Mahrez's effort from 12 yards came back off the post.
The result sees Algeria go home but that, plus Sierra Leone's defeat to Equatorial Guinea means minnows Comoros, who are ranked 132nd in the world, qualify for the last-16 as one of the best four third-placed teams.
Needing a win to stay alive, Algeria failed to get going at the beginning and deservedly found themselves behind at half time.
The Ivory Coast took the lead when AC Milan star Kessie adjusted his feet well to fire into the corner with his left peg to round off a slick move.
Their second would've left Algeria boss Djamel Belmadi raging as Sangare found himself in oceans of space as he headed in a free-kick on the right.
Algeria improved after the break but the game was taken away from them on 54 minutes as Pepe curled the ball home. Substitute Bendebka's 73rd-minute header was Algeria's first goal of what's been a shocking tournament for them.