Abdelkader Laifaoui broke the quarter-final deadlock from a penalty one minute before half-time and Hocine Metref added a second goal three minutes into stoppage time on an artificial Khartoum Stadium pitch. Algeria will return to the venue in the Sudanese capital next Tuesday for a semi-final showdown with competition favourites and title holders Democratic Republic of Congo or Tunisia.
The result thrilled Algerian coach Abdelhak Benchika, who set a place among the last four as the minimum target for his 23-man squad ahead of the biennial tournament restricted to home-based footballers. While many in the Algerian team are combat-hardened African campaigners at club and national team level, the South African side was composed largely of amateurs from third-tier regional league sides.
Premiership and second division clubs refused to free their stars, forcing coach Simon Ngomane to select raw unknowns who defeated Ghana, Niger and Zimbabwe to top Group B and reach the knockout stage.
Algeria finished second behind Sudan in Group A after comfortably defeating Uganda and drawing with 10-man Gabon and the host nation in the three-week second edition of a championship staged by Ivory Coast two years ago.
Although Ngomane expressed pre-match fears about his team playing on the artificial turf for the first time, South Africa had the upper hand early on with Tiyani Mabunya going close from a free kick. However, Algeria improved as the half progressed and South Africa had a let off when Khaled Lemmouchia put Metref through but his feeble shot was parried by goalkeeper Jacob Mokhasi.
South Africa were under increasing pressure and fell behind when Moustafa Djallit was fouled and Laifaoui made no mistake from the penalty spot to give his team a half-time advantage. Hadj Aissa made a big impact when introduced by Algeria in the second half and went close with a glancing header before starting the move that led to the killer second goal from Metref.
Sudan meet Niger in Omdurman later Friday in the second quater-final and Cameroon play Angola Saturday before Tunisia confront DR Congo in other last-eight fixtures.