Despite the lively start, Ezenkosi's first sight on goal came through skipper Ange Lebahi on 21 minutes, with the defender forcing a fine save out of Elvis Chipezeze.
Against the run of play, the travelling outfit were ahead when a cleverly-worked cut back teed-up Inky Masuku to finish beyond Chipezeze on 30 minutes.
Baroka thought they had restored parity ten minutes before the break through Jemondre Dickens' close range finish, but the goal was chalked off by the offside flag.
Baroka were the first side re-shuffle their pack when Mpho Kgoetyane came on for an injured Hassan Banda at the start of the second half.
Five minutes after the break, Bakgaga almost succumbed to another Masuku strike when the Cosmos forward left the defence for dead, but he hoofed the effort over the top.
Whilst attempting a defensive-clearance, Ezenkosi nearly surrendered their lead but the awareness of goalkeeper Cyril Chibwe saved his side's blushes as Baroka upped the tempo.
With 20 minutes remaining, Chibwe came to Cosmos' rescue once again as he popped up with a timely intervention to deny Tebogo Sodi a certain goal with the net gaping.
The National First Division campaigners were able to see out the remaining stages of the half to secure victory and their spot in the round of 16.
Baroka: Chipezeze , Makume, Banda, Gebhardt, Madubanya, Sodi, Patjie, Makgaka, Semenya, Dickens, Mdantsane.
Subs: Ncube , Chinyengetere, Matome, Chivaviro, Mosele, Mongae, Chawapiwa.
Chibwe, Lebahi, Hananumb, Kekana, Mbokoma, Ledwaba, Masuku, Obi, Umukoro, Gie, Ohizu.
Subs: Maziya, Buthelezi, Khwinana, A.Nkosi, Sono, S.Nkosi, Mncube.