Bafana Bafana took the lead just after halftime but three goals in 16 minutes secured maximum points for Christian Gourcuff’s side.
Algeria got its Africa Cup of Nations campaign off to a flyer as it came from a goal down to beat South Africa 3-1 on Monday.
Christian Gourcuff’s Algeria side, the top-ranked national team in Africa, is among the favorites to win the tournament but looked to be heading for defeat when Thuso Phala gave Bafana Bafana a deserved second-half lead at Estadio de Mongomo.
South Africa striker Tokelo Rantie then missed a penalty a few minutes later and that was to prove costly as Algeria fought back to win their Group C opener.
Thulani Hlatshwayo’s own goal pegged Shakes Mashaba’s men back and Napoli defender Faouzi Ghoulam added insult to injury by putting Algeria in front five minutes later.
Islam Slimani then sealed the points with a third goal, which goalkeeper Darren Keet should have kept out, as South Africa was left to reflect on what might have been.
South Africa did not allow its opponents to settle in the first half and it was unfortunate not to be in front when captain Dean Furman rattled the crossbar with a rasping long-range drive 22 minutes in.
Bafana Bafana then suffered a blow when they lost a distraught Rivaldo Coetzee to injury, meaning Siyabonga Nhlapo entered the fray after only half an hour.
South Africa looked increasingly threatening and had two great chances to take the lead just before halftime as Algeria rode its luck.
Sibusiso Vilakazi looked certain to open the scoring when he wriggled free in the penalty area and was poised to apply the finish when Rais M’Bolhi came out to deny him.
Algeria was again indebted to M’Bolhi a minute later, as this time Vilakazi picked out Andile Jali in space in the penalty area and he took his time before seeing his shot kept out by the Philadelphia Union keeper.
M’Bolhi was unable to prevent South Africa from deservedly taking the lead six minutes into the second half, though, when Phala rounded off a fine move.
The lively Rantie flicked the ball back from the byline into the path of Vilakazi, who in turn set up Phala and the midfielder took a touch before firing home from eight yards.
Algeria was unable to live with the pace of Bafana Bafana and Mashaba’s men should have doubled their lead two minutes later, when Aissa Mandi clattered into Vilakazi as he raced into the area and referee Noumandiez Desire Doue pointed to the spot.
Mandi was somewhat fortunate to escape with only a yellow card and Algeria was given another let off when Rantie’s penalty hit the crossbar and went behind for a goal kick.
Algeria responded and Keet denied Slimani, who reacted quickly but saw his header palmed onto the post by the South Africa keeper.
Gourcuff’s men were then gifted an equalizer when defender Hlatshwayo could only head Yacine Brahimi’s cross into his own net after 67 minutes.
And worse was to come for South Africa five minutes later, when Ghoulam surged into the penalty and found the back of the net with a left-footed strike that Keet ought to have done better with at his near post
Slimani then stole in to add a third goal seven minutes from time, as Keet had another moment to forget by allowing a tame shot to squirm under his body and into the net.