Morocco appeared on course for victory after Kautar Azraf broke the deadlock, giving the hosts a 1-0 advantage before the interval. The Atlas Lionesses then thought they had extended their lead after the restart, but Maryam Atiq's effort was disallowed.
Algeria continued to push for a way back into the contest and eventually found their reward seven minutes from time. Lina Boussaha struck in the 83rd minute to level the score and force the match into a shootout.
Neither side could find another goal during the remainder of normal time, leaving the bronze medal to be decided from 12 yards. Algeria held their nerve to prevail 3-2 in the penalty contest, securing third place and leaving Morocco to settle for fourth.
The achievement caps a landmark tournament for Farid Benstiti's side. Algeria reached the semi-finals for the first time in their WAFCON history, going further than they had ever managed previously in the competition.
Their run to the last four also secured Algeria's maiden qualification for the FIFA Women's World Cup, which will be staged in Brazil in 2027.
The bronze medal therefore adds another significant milestone to a campaign that has already rewritten the history of Algerian women's football.