Spokesman Ronnie Mamoepa said this would allow him to remain in South Africa for the next four years.
Semugoma was detained at OR Tambo International Airport on Monday on his return from Zimbabwe because his multiple entry visitors’ visa had expired.
A number of activist groups had been worried that Semugoma could face discrimination if deported to Uganda because of pending laws against homosexuality.
On Thursday, the department of home affairs sought leave to appeal against an interim court order which would allow Semugoma to enter the country.
Mamoepa said the High Court in Johannesburg ordered Semugoma be permitted to enter South Africa, provided he withdrew other pending applications with the department.
This would not preclude Semugoma from re-applying when his exceptional skills work permit neared expiry, Mamoepa said.
Semugoma could now legally enter South Africa, as his paperwork was compliant with the Immigration Act.
Semugoma previously travelled in and out of South Africa using a multiple entry visitor’s visa.
Mamoepa said that Home Affairs Minister Naledi Pandor decided to grant Semugoma the work permit as part of South Africa’s determination to recruit skilled people to help develop the economy.
“The department has never before denied Dr Semugoma the right to enter South Africa subject to full compliance with our country’s immigration laws, as evidenced by the fact that he was previously issued with a multiple visitor’s visa entry.”