But substitute Madjid Bougherra rescued Algeria with a last-gasp header to force the contest into extra time.

Hameur Bouazza then took advantage of disastrous defending to send Algeria into the semi-finals.

"I am really happy. We came up with what we wanted," said Algeria coach Rabah Saadane.

"I wasn't surprised by my team, but more by the decline of the Ivory Coast side. The critics said after we beat Mali (1-0) that we only scored goals from dead ball situations, well here we scored three goals from open play!"

The Elephants thought they had found an equaliser in extra-time injury time but Kolo Toure was wrongly ruled offside.

For a team which had eight days to prepare, Ivory Coast looked like a spent force as the game went beyond 90 minutes.

Didier Drogba was taken down in the 15th minute - but no penalty was given

And Algeria, not given much chance prior to the game, have sent a message to the World Cup - and Fabio Capello's England - that they are not to be underestimated.

For all of Ivory Coast's attacking prowess, it was ultimately woeful defending which proved to be their downfall.

After Keita appeared to have the game won, Elephants goalkeeper Boubacar Barry looked dumbfounded as his defence stood motionless when Rangers star Bougherra rose to nod home and make it 2-2.

The winning goal was much the same, this time Karim Ziani's cross arriving for Bouazza, who plays for Championship side Blackpool.

He rose above some criminally static defenders to make it 3-2 after just two minutes of extra time. Kader Ghezzal missed a simple chance to add further insult to injury in the 106th minute.

"Many people wrote our chances off," said Rangers defender Bougherra. "This victory is for the people of Algeria all over the world."

It was an outcome few would have predicted as Ivory Coast took an early lead through Kalou. The Chelsea man managed to stay onside as a deflected pass landed at his feet and he slid it past Fawzi Chaouchi after just four minutes.

Ivory Coast then dominated proceedings, but, aside from a decent effort from Kalou which hit the side netting, they had nothing to show for their efforts.

In the 15th minute, Didier Drogba caught up with a through ball from Gervinho, ran into the area and was abruptly taken down by Rafik Halliche. A clear penalty - but the referee waved play on.

Slowly, Algeria pulled themselves back into the game. It became a battle of two distinct styles - Algeria's posession football versus the thrilling counter-attack of the Ivorians.

In the 40th minute, it was Algeria's approach which paid off.

Kader Keita thought he had won it for Ivory Coast after his effort

A speculative diagonal ball from midfield landed at the feet of Karim Matmour, whose right-footed shot left Barry stranded on his line. A fine finish to make it 1-1 at the break.

The second half saw both teams produce some decent chances - Kalou and Zakora came close for Ivory Coast and Matmour broke through and forced a good smothering save from Barry at the other end.

But it was in the 89th minute when the game suddenly came alive.

Kadar Keita, an Ivorian substitute, unleashed a left-footed shot which flew past the goalkeeper, smacked the underside of the crossbar and hit the back of the net.

But more drama was to come with Algeria's sensational late equaliser and subsequent extra-time winner.

They will now eagerly await the result of Monday's tie between Egypt and Cameroon to find out their opponents in the semi-finals.

Ivory Coast coach Vahid Halilhodzic was furious his team had let victory slip from their hands.

"After we scored our second goal it should have been game over. What happened is unacceptable," said Halilhodzic, who suffered his first defeat in a competitive game since taking over at the head of Ivory Coast in 2008.

"Is the problem physical or psychological? It cannot be physical because when you are one goal up with only one minute left, you just sit back and clinch victory. Algeria deserve their victory."

This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.