The South Africans, who last competed in an international tournament in December 2019, had to dig deep for this win - which also saw them qualify for the Commonwealth Games in Birmingham in July - and only scored the winning try in injury time when Eloise Webb scored her only, but most important five pointer of the tournament.
Madagascar, by reaching the final, also qualified for the Rugby World Cup Sevens in Cape Town in September and looked set to shock the South Africans, who won the title in their last appearance of this continental showpiece in 2019.
They scored first in both halves of the match to extend their 7-5 lead at the break to 14-5 before Lusanda Dumke and Webb’s second half tries, complimented by a sublime run by Nadine Roos before the break, secured the South African win in the most dramatic fashion. Time was long gone when Webb received the final pass to score.
For Webb, who was part of the match-winning squad in 2019 as well, the last play was a memorable one.
"The forwards need the credit for those last seconds of the game," Webb said afterwards.
"They kept the ball alive and it was easy for me, as I just needed to ground the ball. It was a wonderful moment, no doubt, even more so because it was a team play that worked perfectly."
Earlier in the day, South Africa outplayed Ghana 17-5 in the Cup quarter-finals before easing past Tunisia 31-0 in the semi-finals.
The match against Ghana was not the best start to the day, but thanks to an early Dumke try and a brace by Anacadia Minnaar, the team could prevail.
A clinical second half effort dismantled Tunisia. Tries by Roos and Mathrin Simmers edged their team ahead 10-5 at the break, but the second half saw scores from Simmers, Asisipho Plaatjies and Donelle Snyders booking them a place in the final.
South Africa 17 (10), Ghana 5 (0)
South Africa - Tries: Lusanda Dumke, Anacadia Minnaar (2). Conversion: Eloise Webb.
South Africa 31 (12), Tunisia 0 (0)
South Africa - Tries: Nadine Roos, Mathrin Simmers (2), Asisipho Plaatjies, Donelle Snyders. Conversions: Roos (3).
South Africa 15 (5), Madagascar 14 (7)
South Africa - Tries: Nadine Roos, Lusanda Dumke, Eloise Webb.