South African authorities on Thursday released a gay Ugandan activist after four days in custody, following an outcry from rights groups that he would be targeted if deported home.
Immigration officials had barred Paul Semugoma, a medical doctor and critic of pending anti-gay legislation in Uganda, from re-entering South Africa on Monday due to a lapsed visitor's visa.
Semugoma was freed after a court settlement between his legal team and the department of Home Affairs granting him a work permit and allowing him into the country.
"It's all worked out," said Ayanda Khumalo, a lawyer acting for the Ugandan.
"The basis of the settlement is that the department will give him an exceptional skills work permit and he will be released today," she said.
Semugoma was "overwhelmed and overjoyed" after his release, she added.
Uganda's parliament in December passed a controversial anti-gay law that will see homosexuals jailed for life, which President Yoweri Museveni has said he will sign into law.
The decision on Thursday follows a legal tussle between the authorities and Semugoma's team.
According to rights groups lobbying for his release, two applications by Semugoma for a work permit had been lost by authorities.
The department said he was barred as his visitor's visa had expired.
Semugoma has volunteered at the Johannesburg-based Anova Health Institute, which focuses on HIV, for three years.
South Africa upholds same sex rights, including marriage, but was accused of being complicit with the anti-gay sentiment of the government over the matter.
[Image via Agence France-Presse]