Wilfried Bony scored twice to take Ivory Coast into the semi-finals of the Africa Cup of Nations.
The new Manchester City striker headed the Elephants in front from a right-wing cross by Max Gradel.
Hilal Soudani equalised for Algeria against the run of play early in the second half and then forced goalkeeper Sylvain Gbohouo into a brilliant save.
Gbohouo was rewarded when Bony headed in Yaya Toure’s free-kick and Junior Tallo set up Gervinho for a late third.
The margin of victory flattered Ivory Coast in what was an even contest and before former Arsenal striker Gervinho confirmed the result on the break, they had been under pressure from Algeria.
Their defence seemed all over the place at times and semi-final opponents DR Congo will have taken note.
Algeria, in the quarter-finals for the first time since 2010, made the brighter start to the contest and almost went ahead in the ninth minute.
Yacine Brahimi raced into the left-hand side of the penalty area and the Elephants’ defence failed to deal with his cross, allowing Soudani to get in a shot which was well held by Gbohouo.
In the 21st minute, Riyad Mahrez volleyed over from close range but then Ivory Coast hit back.
Two minutes later, Gradel floated in a free-kick from the left and Serge Aurier’s downward header hit the base of the post and then in the 26th minute they took the lead.
Gradel was again involved as he delivered a testing cross from the right and Bony escaped the defence to head home from eight yards.
Bony shot wide from distance towards the end of the first half before at the other end, Saphir Taider’s sharp volley was confidently saved by Gbohouo.
The start of the second half mirrored the start of the first with one team dominating but the other one scoring.
This time Ivory Coast were the team who started on top but a comedy of errors in their defence after a deep cross into their penalty area finally saw the ball fall to Soudani, who fired it home.
That sparked a spell of dominance from the Desert Foxes with Gbohouo twice having to clear his lines before he made an amazing 66th minute save from Soudani’s point-blank effort.
The momentum changed and two minutes later Bony restored Ivory Coast’s lead when he climbed highest to head Yaya Toure’s set-piece inside the near post.
Algeria piled on the pressure in the closing stages but could not find an equaliser and Gervinho finished them off when he passed the ball into the net.