A debut goal for Mpho Makola gave South Africa a huge shot in the arm as it beat Senegal 1-0.
Shakes Mashaba's side lost 3-1 to Mauritania on the weekend and looked to be heading for a stalemate in the Nelson Mandela Challenge clash as it failed to break down Aliou Cisse's men.
However, Makola's fine strike from distance ended the new Senegal coach's perfect recent record and gave Bafana Bafana a big lift ahead of a return to 2018 FIFA World Cup qualifying in November.
Mashaba made seven changes to the team which started the defeat to Mauritania, with Itumeleng Khune captaining the side, but South Africa struggled for any sort of control on the ball as Senegal began on the front foot.
The first chance of note fell to Bafana Bafana, however, with Khadim Ndiaye off his line smartly to deny the run of Thamsanqa Gabuza.
Gabuza then had a penalty shout waved away after bursting into the area and going down under pressure from Kara Mbodji, with the referee unmoved by his appeals.
Makola came closest to opening the deadlock inside the first 32 minutes as his free-kick fizzed narrowly wide, but chances were few and far between until the closing stages of the half.
Khune - who received treatment for a pain in his leg earlier in the half - was called into action 10 minutes before the break, keeping out a fierce free-kick from Diafra Sakho.
Sibusiso Vilakazi then teed up Gabuza inside the area and the Orlando Pirates striker slammed his effort off the crossbar and he was denied by Ndiaye from distance a moment later as South Africa finished strongly.
Vilakazi himself was thwarted by substitute goalkeeper Lys Gomis eight minutes into the second half as Mashaba's side continued to look the more likely to break the deadlock, and the 25-year-old spurned the best chance of the game when he somehow contrived to miss with the goal gaping after being played in by Andile Jali.
The home side finally broke the deadlock with just under quarter-of-an-hour to play, as Makola marked his debut with a fine strike from outside the area that left Gomis helpless.
Gomis denied Gabuza just three minutes later and Khune kept out a straightforward shot as South Africa held on for a morale-boosting victory.