Asamoah Gyan who has not been fit and has had just few training scored late to give Ghana a dramatic late winner to keep alive his side's hopes of reaching the Africa Cup of Nations quarter-finals. Gyan snatched an unlikely victory when he charged towards a long ball and angled in a drive in stoppage time.
Algeria missed the only other clear chance when Nabil Bentaleb side-footed well wide from 12 yards on 20 minutes.
The game had looked set to remain goalless until Gyan's late strike.
Gyan missed Ghana's opening match loss to Senegal because of a bout of malaria and although he was understandably lacking sharpness on his return, he persevered until the very end to rescue his team.
Bentaleb, Befoldil and Badu were lucky to stay on the pitch after a confrontation
The striker has now scored in each of his last six games for the Black Stars, who did not make life easy for their talisman as they toiled to create chances in a scrappy game.
Ghana failed to muster a single effort at goal in the opening period as the Algerian defence, well marshalled by returning captain Madjid Bougherra, easily coped with a succession of hopeful punts forward.
Yet Algeria fared little better, managing only two efforts, both of which were wayward. While Faouzi Ghoulam's early attempt was purely speculative for Algeria, Bentaleb's side-footed shot from inside the box was a waste of an excellent opportunity forged by clever interplay between Yacine Brahimi and Aissa Mandi.
In an overly physical first half, there might have been more red cards than shots, but somehow Bentaleb, Ishak Belfoldil and Emmanuel Badu all escaped without punishment after the three were involved in an ugly bout of shoving.
Quality continued to be in short supply after the break, but at least Ghana began to show some attacking intent.
However, Gyan could not direct a difficult diving header on target and dragged another shot well wide and Ghana striker Jordan Ayew flicked over an improvised volley at the near post.
At the other end Bentaleb fizzed a low shot wide of the right post after being played in by Brahimi.
It proved to be a costly miss for Algeria as Gyan ran on to a long ball over the top by substitute Mubarak Wakaso and sent a scruffy shot into the bottom left corner.
Ghana coach Avram Grant: "Asamoah Gyan was not fit – he didn't train like he needed to – but he's Asamoah Gyan, if you look at the stats and his behaviour in the dressing room.
"You know I have been coach of some of the great players – he's one of the greatest. First – he always scores when you need him. Second – he's good for the spirit of the team – he's a very good captain."
Algeria coach Christian Gourcuff: "If you analyse the match in terms of organisation, we were much more coherent than against South Africa. We weren't composed enough going forward, which is connected to our tempo on the ball, which was too slow, on a surface which didn't really lend itself to a passing game.
"It's true that in the second half we had a couple of chances, including one which fell to Nabil Bentaleb.
"Obviously the last goal is very hard to swallow for us. There is no other choice but to adapt. There's no use in our doing calculations. We just have to win on Thursday. A draw is no longer good enough for us. Clearly we have to aim to attack the goal."