Vahid Halilhodzic's team were expected see off the West African minnows, but it looked like there could be shock on the cards when Emmanuel Adebayor gave Togo a first-half lead against the run of play.
Algeria dominated the match throughout the second half but appeared incapable of scoring. Their fate was sealed when substitute Dove Wome struck in stoppage time.
Find out how all the action unfolded with our minute-by-minute commentary below.
5.40pmGood afternoon and welcome to out live text coverage of the Africa Cup of Nations Group D clash between Algeria and Togo. This is a vital game for both teams with Ivory coast having already claimed one of the group's qualifying spots with a 3-0 win over Tunisia earlier today.
5.54pmAlgeria's Vahid Halilhodzic: "I've seen the determination in my player's eyes. They have an inner force. There's still a good spirit in the squad. I know our backs are against the wall. We have to look for two victories. We're going to do everything to win because the only solution is victory."
5.46pmTogo's Didier Six: "After the match against Ivory Coast we had a meeting, right afterwards because we had to recover quickly. The players now don't think about Ivory Coast, they're only thinking about the game against Algeria. In this group we are maybe the little team but I know my team, we have good players. It's a difficult group but against Ivory Coast we proved that we can play good football and are good enough to go to the quarter-finals."
5.50pmAlgeria are the clear favourites here today. They are the second-highest ranked team in Africa and were tournament winners in 1990. Togo, on the other hand, have never progressed beyond the group stage.
0 minWe are under way here at the Royal Bafokeng Stadium.
2 minTogo are the first side to venture into the final third but their ambitions are quashed as an offside flag goes up against Gakpe. He picks up the first booking of the game for a clear foul one minute later.
4 minTogo's Amewou goes in hard on Kadir, but he timed his challenge just right. Algeria looking the more organised of the two sides in the early stages, playing some good passing football.
6 minHalf-chance for Algeria as Lacen fails to connect with Slimani's cut-back. Kadir blazes one over the bar moments later following a set piece to claim the first shot on goal.
9 minA half-chance falls to Togo at the other end as Adebayor races forward to latch onto a long ball, but Algeria keeper M'Bohli is quick enough off his line to get their first.
11 minAlgeria are piling on the pressure now and living up to that favourites tag. They put a series of crosses into the Togo area before Feghouli forced a corner with a deflected strike.
15 minSHOT! A golden opportunity for Algeria to break the deadlock goes begging as Islam Slimani makes a good run into the Togo area and lashes on wide of the post. That should have been the opener.
16 minCHANCE! Togo threaten at the other end as Salifou finds Adebayor in the box with a cross from out wide, but the Spurs man can't get enough on the header and it goes out for a goalkick.
18 minAmewou dispossesses Feghouli with a great tackle in the Togo area but he can't prevent the corner. Feghouli takes it himself but Agassa makes the catch.
22 minCHANCE! Guedioura gets his head to a corner and forces a good save from the outstretching Agassa. The keeper is called into action again moments later to smother Lacen's deflected drive.
24 minAlgeria are controlling this contest, while Togo look very short of ideas going forward. Feghouli has been the stand-out player up to now, showing some superb touches and creativity in the final third.
27 minBelkalem concedes a cheap corner allowing Togo to throw some bodies forward, but their rare attack grounds to a halt as Romao is adjudged to have committed a foul when the ball is played in.
32 minTogo snatch a surprise lead through their captain Adebayor! Ayite set him up for a one-on-one with M'Bohli with a deft headed pass and the Spurs man made no mistake from close range. That's his first ever Africa Cup of Nations goal!
36 minCHANCE! Slimani really should have levelled for Algeria there! He latched onto a long ball into the box, took it down and fired directly at Agassa between the Togo sticks. Algeria will have to be more clinical than that if they want to stay in this competition.
38 minSlimani has been wasteful in front of goal but Algeria continue to create chances. Lacen has just fired one over the bar from more than 30 yards back, summing up his side's fortune in front of goal tonight.
38 minBOOKING! Adlene Guedioura goes into the book for a crunching tackle on Gakpe.
41 minTogo will be relieved to hear that half-time whistle. Algeria's final ball has been poor but they have still created plenty of chances and kept their opponents under constant pressure.
45 minGuedioura lets fly with an ambitious 30-yard effort that sails well over the bar, just before the fourth official indicates that there will be one minute of stoppage time.
6.45pmWe could have a real shock on out hands here. Not only are Togo on course to cause an upset thanks to Adebayor's goal, the second-highest ranked team in Africa could be on their way out of the competition.
6.48pmAlthough Algeria have had the better of the possession and created more chances, Vahid Halilhodzic's side have been criminally wasteful upfront and allowed themselves to fall victim to the counterattack when they fell behind.
6.52pmIn all fairness, Togo have been second-best but they have defended well and managed to catch their opponents on the break, which I think was always their gameplan.
6.55pmExpect more of the same in the second half as Algeria fight for their lives and Togo continue to defend deeply and use Adebayor's pace to their advantage.
45 minWe are back under way. Algeria have 45 minutes to keep their Africa Cup of Nations hopes alive.
49 minNibombe produces a vital interception as Feghouli tries to find Slimani in the box. The former goes down in the box after being clipped by Romao moments later and appeals for a penalty. I've seen them given in the past, but the ref isn't interested. The Algeria players are fuming!
50 minAnd Lacen is booked for showing dissent after the referee refuses Feghouli's penalty shout. A needless booking, really.
53 minA half-chance falls to Algeria as Soudani gets his head to a cross in the Togo area. Dare Nibombe showed good composure at the back moments earlier to thwart another Algeria move.
58 minAnother Algeria penalty appeal as Slimani is hacked in the box by Dakonam Djene. The Togo defender missed the ball and took his legs away. That one was a cast-iron penalty!
62 minA rare attack for Togo results in a corner but the move collapses as Adebayor strays into an offside position. Mamah Gaffar goes into the book moments later for a late challenge on Hilal Soudani.
64 minSHOT! Kadir goes on a mazy run and lets fly, only to see his effort cannon off a yellow short and end up behind for an Algeria corner.
65 minSUBSTITUTION: Algeria hook Kadir and send on Bezzaz with just 25 minutes to save their Africa Cup of Nations campaign. Feghouli sends a free kick over the bar shortly after the restart.
69 minFrustration for Halilhodzic's side as yet more chances go begging. Feghouli sends a cross into the Togo box but it's far too deep and ends up going behind. Slimani heads over from 10 yards out moments later.
75 minSUBSTITUTION: Algeria throw on Aoudia for Slimani, who has been wasteful all evening. Mani has also replaced Gakpe for Togo.
78 minThe match stats confirm that Togo have had one shot on target all evening. Algeria are preparing to take their 17th corner at the moment. Those figures just tell it all!
79 minSHOT! Togo put Algeria on the back foot for a change as Wome dashes forward and lets fly from 25 yards, only to put the ball into row z.
82 minBezzaz shoots wide for Algeria and Togo go straight in the attack from Agassa's goalkick. Adebayor has acres of space up front, but his teammates fail to give him the support he needs and the danger is cleared.
83 minSUBSTITUTION: One last throw of the dice for as Bouzza replaces Lacen. I can't believe they are losing this game. Sometimes there is simply not justice in football!
86 minWe are in the midst of a delay as one of the goalposts has been dislodged. Looks like it could take a few minutes to rectify the situation.
87 minThere's a real carnival atmosphere among the Togo supporters. This would be one hell of a scalp for them. If the scoreline stays the same, it will set up what is essentially a knockout clash with Tunisia in their next Group D fixture.
90 minExpect eons of stoppage time as the entire Togo goalframe has been removed. We are now waiting on a new one. I didn't realise they kept spare goalframes at grounds.
90 minWe are back under way. There's at least four minutes of normal time still to play by my calculations, along with whatever the referee chooses to add for injuries. Meanwhile, Togo have brought on Bossou for Ayite to protect the back four.
90 minBOOKING! Akakpo is shown the yellow card for kicking the ball away as tensions start to hit critical mass. The closing stages will be a real test of Togo's nerve. Do they have what it takes to see this through?
90 minThe fourth official has just indicated that there will be a whopping 13 minutes of stoppage time to play. That should fire up Algeria!
90+4 minAnd that is surely the nail in Algeria's coffin! More devastating counterattacking football from Togo releases the substitute Wome, who keeps his cool to slide the ball past M'Bohli and make it 2-0!
90+6 minWhat a result for the West African minnows! Algeria were one of the pre-tournament favourites and they have sent them packing. That Tunisia clash should be mouthwatering indeed!
90+7The Algerians look despondent. Although we still have eight minutes to play, this is a team that have accepted their fate. I think a lot will be made of that penalty they should have had in the 58th minute. That could quite easily have changed the outcome of the game.
90+10Into the tenth minute of added time now. There will be plenty for Algeria to reflect on after this tournament. They have played well in both their game, yet seem incapable of scoring.
8.15pmIt's all over! A fantastic result for Togo even if the 2-0 scoreline is a little flattering. Algeria crash out of the competition despite putting in a dominant performance tonight, while the West African minnows set up a crunch clash with Tunisia in their final group game.
8.19pmThat's all from me here tonight. Many thanks for joining us. Be sure to visit Sports Mole tomorrow for all the action from Cape Verde vs Angola and Morocco vs South Africa.