Cameroon qualifies automatically as host while Senegal secured a spot Monday (AEDT) by winning in Guinea-Bissau thanks to a Sadio Mane goal.
Andy Delort and captain Mahrez gave the Desert Foxes a two-goal advantage in Harare that was halved just before half-time when Knowledge Musona netted.
Algeria coach Djamel Belmadi took off Delort and Mahrez as he made five second-half substitutions within 12 minutes, but the bold move backfired when Prince Dube equalised eight minutes from time.
Drawing ended the perfect three-win record Algeria took into a match played behind closed doors because of the coronavirus, but it guaranteed them a top-two finish in a section including Zambia and Botswana.
Zambia, hoping for a resurgence under Serb coach Milutin 'Micho' Sredojevic, suffered a blow to hopes of accompanying Algeria from Group H when it fell 1-0 away to Botswana.
Mosha Gaolaolwe scored what proved the only goal in Francistown after just six minutes and it lifted Botswana to third, one point behind Zimbabwe.
This was the third loss in four group matches for 2012 African champions Zambia, which will host Algeria and visit Zimbabwe during the final two matchdays next March.
Uganda suffered a shock loss 1-0 away to South Sudan and Burkina Faso drew 0-0 in Malawi to miss out on chances to qualify from Group A.
Uganda-born Tito Okello condemned his country of birth to a first defeat in the section when he converted a first-half penalty in a qualifier marred by two red cards.
Gambia regained first place in Group D from Pierre-Emerick Aubameyang-captained Gabon after winning the top-of-the-table clash 2-1 in Bakau.
Modou Barrow and Musa Barrow scored to put the Scorpions in control until a late goal from Bruno Ecuele Manga created a tense finish.
Cameroon is part of the qualifying competition to gain match practice and increased its Group F lead to six points after a 2-0 win in Mozambique with Vincent Aboubakar among the scorers.
In Manzini, eSwatini was eliminated and Congo Brazzaville strengthened a grip on second place behind Senegal after a 0-0 draw.