South Africa needed at least a draw to progress, but the result ends Tunisia's hopes of advancing.
Menzi Masuka scored the all-important goal in the 85th minute to secure South Africa's place in the last four.
South Africa finished second in the group on six points.
The hosts Senegal finished top of Group A with a third consecutive win, beating Zambia 1-0 in Dakar.
Mohamadou Diallo scored for Senegal in the third minute to inflict a third straight defeat on Zambia who are eliminated.
Senegal and South Africa will both now have to wait until Saturday to see who they will play in the semi-finals.
Senegal will play the second placed team in Group B, whilst South Africa will face the Group B winners.
Both semi-finals will be played on Wednesday 9 December.
The tournament also serves as a qualifying competition for next year's Olympic Games with the top three finishers booking a place in Rio.
South Africa beat Tunisia 1-0 in the final game of Group A in M'bour to advance to the Africa Under-23 Cup of Nations semi-finals and keep their Olympic hopes alive.