Trailing 2-1 with the match in stoppage time after 90 minutes, the defender's powerful header set up an additional 30 minutes of extra time.
Overall, it was an impressive display by Rabah Saadane's team, who were twice forced to come from behind having trailed to a Salomon Kalou strike and then a Kader Keita effort at the death.
In between, Karim Matmour scored an equaliser just before half-time, before Bougherra stepped in.
Blackpool forward Bouzza netted a dramatic winner two minutes after coming on to hand his side a well- deserved win against Vahid Halilhodzic's below-par Elephants for whom Hibs' Sol Bamba was a major figure in defence.
It was a dramatic turnaround after the Algerians fell behind four minutes in.
Yaya Toure's shot was deflected into the path of Kalou on the right side of the penalty area and the Chelsea striker executed a low finish beyond Faouzi Chaouchi at the near post.
The Algerians gradually took charge, though, and the pressure eventually told five minutes before half-time when a long ball from Antar Yahia bounced loosely on the edge of the Ivorian penalty area, with Matmour forcing his way in between two defenders and finishing emphatically.
There was a crucial moment in the 68th minute when Bamba was dispossessed by Matmour on the edge of the penalty area, but the Borussia Monchengladbach midfielder saw his shot excellently kept out by Boubacar Barry. Saadane's men continued to pile on the pressure, but their west African opponents were still a threat on the break as Yaya Toure illustrated with another shot that forced a full length dive from Chaouchi, but drifted narrowly wide. Five minutes from the end and having just come on, substitute Kader Keita led another sweeping counter attack with a pin-point pass to Gervinho, but the Lille forward blasted his effort over.
The Galatasaray midfielder then smashed in a 25-yard screamer that went in off the upright and looked to have won the game with just a minute to play.
Enter stoppage time and the Algerians refused to give in. A sweeping cross from the left, along with sloppy defending from the Ivorian defence, allowed Bougherra in and the Ibrox defender headed in powerfully.
The Elephants looked shell-shocked and their opponents took full advantage less than two minutes into extra-time.
Bouazza, introduced after the 90 minutes ended, was left unmarked at the far post and leapt high to nod in Ziani's cross to put Algeria ahead for the first time.
Their opponents tried to respond with Drogba's fierce 18-yard shot somehow blocked by Chaouchi, who helped his side stay 3-2 ahead after 105 minutes.
Straight from the restart there were chances aplenty for the Algerians to kill off the game as Ivory Coast went for broke – Ghezzal mis-hitting the best of the chances in the form of a virtual tap-in that seemed almost impossible to miss.
At the other end, Bamba put a goal-mouth scramble for his side wide, while the final attempt, which came to Kolo Toure and was expertly executed into the back of the goal, was judged offside as the tournament favourites bowed out.
Algeria will next face either defending champions Egypt or Cameroon.
Meanwhile, an early goal from Asamoah Gyan crushed the host nation's dreams as Ghana eliminated Angola 1-0 in their quarter-final last night. Gyan struck a perfectly weighted through ball from Kwadwo Asamoah wide of Angola's goalkeeper Carlos Fernandes for the decisive goal in the 16th minute.
Angola striker Manucho was guilty of missing two easy chances either side of the interval. Ghana, the last Nations Cup hosts to lose in the quarter-finals ten years ago, will next play in Thursday's semi-final against the winner of today's quarter-final between Nigeria and Zambia in Lubango.