A man looks in 2012 at an advertising by campaign group Avaaz in the state-owned Ugandan newspaper The New Vision, protesting against an anti-homosexuality bill. Picture: MICHELE SIBILONI

Johannesburg - Rights groups urged South Africa's government Wednesday to urgently halt the deportation of a Ugandan doctor and gay rights activist over fears that he will be in danger if sent home.

Paul Semugoma, a medical doctor who has lobbied against Kampala's tough pending anti-homosexuality legislation, was detained in South Africa on Monday by immigration officials.

He was detained at OR Tambo International airport in Johannesburg when returning from a trip to Zimbabwe on Monday.

Lawyers fighting for his release say they won a court injunction to prevent his deportation back to Uganda on Wednesday, but that authorities had ignored the order and tried to usher him on to a flight.

Immigration officials denied the claim and said they had appealed the injunction.

“We've been refused contact with him so we don't know how he is physically,” Ayanda Khumalo, a lawyer acting for Semugoma, told AFP.

“But from speaking to him over the phone, he's not well at all, he's a bit distraught and he's losing hope I guess at this stage.”

Semugoma telephoned his lawyers on Wednesday afternoon, saying that officials were trying to put him on a flight to Uganda.

He reportedly refused to get onto the airplane.

Six rights groups issued a statement on Wednesday calling on South Africa's government not to expel Semugoma, saying he was “wanted in Uganda for his activism” around gay issues.

“The human rights situation in Uganda has deteriorated, and the LGBT (lesbian, gay, bisexual and transgender) community is particularly vulnerable at this time,” they said.

“Paul is at risk should he be deported to Uganda.”

Ugandan President Yoweri Museveni has announced he will sign into law a controversial anti-gay bill, passed by parliament in December, that will see homosexuals jailed for life.

Marcus Low of the AIDS activist Treatment Action Campaign said Semugoma had “been a very active opponent of the homophobic law”.

“He would definitely be in danger if he returned to Uganda now because of the current climate and because he is openly gay and he's openly critical of the homophobic law,” he said.

Semugoma has unsuccessfully applied twice in the past to gain a South African work permit. After both applications were turned down in 2012, he was given a visitor's visa by the Department of Home Affairs that allowed him to travel in and out of the country, said the rights groups.

But officials say that Semugoma's detention was due to his visa having expired.

Semugoma has volunteered at the Johannesburg-based Anova Health Institute, which focuses on HIV, for three years.

Homophobia is widespread in Uganda. Prominent gay rights campaigner David Kato was bludgeoned to death in 2011 after a newspaper published photos, names and addresses of Ugandan gays with a banner reading “Hang Them”.

South Africa is the only African state where same-sex marriage is legal and discrimination based on sexual orientation is constitutionally outlawed.