South Africa's men and women's booked their places at Tokyo 2020 with final-day victories at the International Hockey Federation African Olympic Qualifier in Stellenbosch.
Both sides faced winner-takes-all contests at Stellenbosch University to secure their ticket to the Olympics.
The men's team had a fierce battle with Egypt and had to dig deep to top the group, trailing 1-0 at half-time.
Ahmed El-Ganaini had put Egypt ahead on 30 minutes before three goals in four minutes from Nicholas Spooner turned the game on its head.
Ashraf Said reduced the deficit in the dying moments but South Africa held out for a table-topping victory and their place in Tokyo.
Elikem Akaba scored twice as Ghana sealed third place by defeating Zimbabwe 4-3.
Michael Baiden and Johnny Botsio also netted, with Rangarirai Mungwiniri, Gift Chomunorwa and Tendayi Maredza scoring for Zimbabwe.
Namibia finished bottom of the table after losing 3-1 to Kenya.
Willis Okeyo, Constant Wakhura and Festus Onyango put Kenya on the victory trail before Nico Neethling grabbed a late consolation for Namibia.
For the women's team, qualification proved much easier as they cruised to a 6-0 victory against Ghana, who had trailed them in the group by two points.
Attacking from the outset, South Africa forged a 3-0 half-time lead, Lilian Du Plessis scoring either side of a Robyn Johnson strike.
Du Plessis sealed her hat-trick in the second half with Sylvia van Jaarsveldt and Lisa-Marie Deetiefs completing a fourth successive win as South Africa topped the group with 12 points.
Zimbabwe had earlier won 3-2 against Namibia to earn third place.
Sophie McDonald opened the scoring on two minutes before a Nicola Watson brace made it 3-0 after 38 minutes.