(CNN) -- Algeria sent a star-studded Ivory Coast side crashing out of the Africa Cup of Nations with a dramatic 3-2 win in extra-time in their quarterfinal in Cabinda on Sunday night.
Earlier, a depleted Ghana also reached the semifinals with a 1-0 win over hosts Angola in Luanda.
An injury-time equalizer from Madjid Bougherra had denied Ivory Coast victory and extra-time had barely started when Karim Ziani sent in a fine cross from the left and substitute Hameur Bouazza headed the winner.
Ivory Coast could offer little more although they had the ball in the net at the end of the second period only for Yaya Toure's effort to be struck out for offside.
The Elephants of the Ivory Coast took an early lead against their fellow World Cup qualifiers as Chelsea's Salomon Kalou was left unmarked in the penalty area and scored with a crisp low shot.
His teammate Didier Drogba had strong claims for a penalty waived away as the Ivory Coast dominated early, but Algeria clawed their way back into the match and scored a deserved equalizer approaching halftime.
A hopeful ball forward was neatly controlled by Karim Matmour and he equalized with an unstoppable shot.
In the second half Kalou shot just wide and a subdued Drogba should have connected in front of goal before Matmour was sent through and denied by Ivory Coast keeper Boubacar Barry.
Ivory Coast substitute Kader Keita then put Gervinho clean through but he made a hash of his effort, but with a minute remaining Keita looked to have scored the winner.
He cut inside to score with an unstoppable 89th minute shot which prompted scenes of wild celebration in his camp.
But Algeria were not finished and from a long cross from the left Glasgow Rangers star Bougherra cleverly diverted home his header to set them on their way to a last four clash with either Egypt or Cameroon.
A triumphant Bougherra told Eurosport that his side had proved their doubters wrong.
"This win is for all Algeria because we played with our hearts," he said.
Four-time champions Ghana, missing the injured Michael Essien and fellow midfield star Stephen Appiah, owed their win to a 16th minute goal from Asamoah Gyan.
Gyan picked up a pass from Kojo Asamoah before firing home to the World Cup finalists facing a last-four tie against either Zambia or Nigeria who meet on Monday.
Angola might have equalized before halftime as Flavio set up Manucho, but he shot over from a good position.
Angola continued to press after the break and Manucho spurned another opportunity from a cross by substitute Job.
Ghana also rode their luck in the last minute as Isaac Vorsah cleared off the line.
Angola coach Manuel Jose said they had done their nation proud and were unlucky to have been eliminated.
"They leave this competition with their heads held high," Jose told gathered reporters
A minute's silence for the victims of the Haiti earthquake was observed before the kickoff.