The Desert Foxes needed a victory to give themselves any chance of reaching the last 16, but were outclassed by the Ivorians, who progress as Group E winners thanks to goals from Franck Kessie, Ibrahim Sangare and Nicolas Pepe.
It has been a frustrating tournament for Algeria, who trailed by three goals when Mahrez sent a spot kick against the foot of the post after Simon Deli tripped Youcef Belaïli.
That effectively ended Djamel Belmadi's side's hopes of mounting an unlikely comeback, though Sofiane Bendebka headed home a 73rd minute consolation to ensure they did not depart without scoring a goal.
Qualifying for the knockout stage was always going to be a tough task for Algeria after taking only a point from their opening two games and it was made harder as Ivory Coast dominated the first half.
Ismaël Bennacer had rasped an early effort against the post for Mahrez’s men before their opponents took the lead in fine fashion.
A slick passing move involving Serge Aurier, Max Gradel and Pepe resulted in the latter cutting the ball back for Kessie, who didn’t need to break stride as he sent a first-time volley into the bottom corner in the 22nd minute.
Sangare extended their lead before the break, arriving unmarked at the far post to power a header home from Aurier’s free-kick and Pepe put the result beyond doubt six minutes into the second period when he curled a composed finish into the far corner from 14-yards.
After Mahrez’s penalty miss, it should have been plain sailing for the Elephants, but Algeria refused to go down without a fight.
Bendebka gave them a glimmer of hope when he finished off a well-worked corner routine from six-yards and Islam Slimani was denied by a brilliant reflex save from Badra Ali Sangaré after being picked out by a pinpoint Mahrez delivery.
Sebsatien Haller thought he’d added a fourth for Ivory Coast in stoppage time, only for it to be ruled out after the final whistle once VAR had shown the striker to be offside when he headed home from close range.
The Elephants will be joined in the last 16 by Equatorial Guinea, who beat Sierra Leonne 1-0 to claim second place in Group E, whilst Algeria exit having finished bottom of the group.