The second leg result in a playoff left the clubs tied at 3-3 on aggregate and the home team advanced on away goals after trailing 3-1 from the first meeting in Pretoria 11 days ago.
Ugandan Onyango was red carded midway through the second half in western city Sekondi for kicking Abbas Mohammed after Bernard Ofori had put the Ghanaians two goals ahead.
Medeama took the lead during the first half when Thabo Nthethe conceded a penalty which Malik Akowuah converted.
Success for the West Africans came after a dramatic two-leg tie in the African equivalent of the Uefa Europa League.
Medeama took a 38-second first-leg lead only to concede three goals in seven minutes during the closing stages.
Swedish coach Tom Strand then secretly abandoned the Ghanaian club in Pretoria and returned to Europe before announcing he was quitting.
Evans Adortey, coach of the Ghana women’s national team, was hastily promoted to replace Strand for the return match against Sundowns.
Arsenio ‘Love’ Cabungula, the leading Confederation Cup scorer this season with six goals, missed a late penalty for Angolan club Sagrada Esperanca as they bowed out.
Esperanca won the return match against Young Africans of Tanzania 1-0 in remote Angolan mining town Dundo thanks to a first-half goal from Cabungula, but were eliminated 2-1 on aggregate.
Title-holders Etoile Sahel of Tunisia were another club to reach the group stage despite losing 1-0 away to Mounana of Gabon in Libreville.
Leading 2-0 from the first leg, Etoile fell behind just before halftime when relentless pressure from the Central Africans resulted in a goal for Louis Ameka-Autchanga.
Etoile, the only club to win all five past and present CAF competitions, are chasing a record-equalling third Confederation Cup title having also succeeded in 2006.
Al Ahly Tripoli of Libya snatched a late 1-1 draw away to Misr Elmaqasah of Egypt in Fayoum 100 kilometres south of Cairo to advance on away goals after a goalless first leg.
Ghanaian Nana Poku gave Elmaqasah an early lead they retained until fivefp minutes from time when Zakareya Al Lafy equalised from a penalty kick.
Mohamed El Fakih converted two penalties as Kawkab Marrakech of Morocco beat Al Merrikh of Sudan 2-0 at home after trailing 1-0 from the first leg.
Morocco will have two clubs among the eight who go into the May 24 groups draw in Cairo as FUS Rabat trounced Stade Malien of Mali 4-0 after a scoreless first encounter.