Solidarity movement ... Kenyan gays and lesbians wear masks to preserve their anonymity as they stage a rare protest, against Uganda's increasingly tough stance against homosexuality outside the Uganda High Commission in Nairobi.

Solidarity movement: Kenyan gays and lesbians wear masks to preserve their anonymity as they stage a rare protest, against Uganda's increasingly tough stance against homosexuality. Photo: AP

Nairobi, Kenya:  Gay rights in Africa suffered another setback after Uganda's President Yoweri Museveni told members of his party he would sign a bill imposing harsh sentences for homosexual acts, including life imprisonment in some cases.

The measure would criminalise "the promotion or recognition" of homosexual relations. After a first conviction, offenders face a 14-year prison sentence. Subsequent convictions of "aggravated homosexuality" could bring a penalty of life in prison.

The announcement of the president's intentions came during a conference of Mr Museveni's party, the National Resistance Movement, according to a government spokesman.

Ugandan President Yoweri Museveni ... has told party members he will he would sign a bill imposing harsh sentences for homosexual acts, including life imprisonment.

Ugandan President Yoweri Museveni: Told party members he will sign a bill imposing harsh sentences for homosexual acts, including life imprisonment. Photo: AP

"The NRM caucus has welcomed the development as a measure to protect Ugandans from social deviants," the spokesman, Ofwono Opondo, said in a post on Twitter on Friday.

According to Amnesty International, homosexuality is illegal in 38 of 54 African countries.

Homosexual acts can be punished by death sentences in Mauritania, southern Somalia, Sudan and northern Nigeria, where justice is carried out according to a version of sharia law. After Nigerian President Goodluck Jonathan signed a law criminalising homosexuality throughout the country last month, arrests of gay people have multiplied amid demands for a crackdown.

Colonial-era Ugandan law already prohibits homosexual acts. An earlier version of the bill, first introduced in 2009 and then withdrawn, included the death penalty in some instances. An international outcry helped scuttle that version, but legislators pushed ahead with a revised one.

The Ugandan Parliament passed the most recent version of the anti-gay legislation in December. Later that month Mr Museveni wrote a letter to Parliament saying that lawmakers had made procedural errors in passing the bill and that in-depth study was needed before it could be taken up again.

Mr Museveni said at the time that he would seek further expert opinions.

"The normal person was created to be attracted to the opposite sex in order to procreate and perpetuate the human race," Mr Museveni wrote in his December letter about the bill, in which he also said that many women became lesbians out of "sexual starvation" because they had failed to get married.

"This comes after 14 medical experts presented a report that homosexuality is not genetic but a social behaviour," Mr Opondo said on Twitter.

Reuters reported that the president's science adviser, Dr Richard Tushemereirwe, told Mr Museveni at the conference that "homosexuality has serious public health consequences and should therefore not be tolerated."

"President Museveni knows that this bill is unconstitutional and that we shall challenge it, after he signs," Frank Mugisha, a Ugandan gay rights activist, said in an email.

He said he did not believe that Mr Museveni would sign the bill in its current form.

"But his political remarks about signing will only increase violence and hatred towards LGBT persons in Uganda," he said, using the initials for lesbian, gay, bisexual and transgender.

Signing the law would be popular with the conservative Ugandan public. Uganda has a powerful evangelical Christian lobby that has supported anti-gay legislation.

"Ugandan traditionalists, religious leaders & politicians have been urging Museveni to sign the Bill," Mr Opondo, the government spokesman, said in another tweet.

Gay rights advocates say that US evangelicals have played a crucial role in pushing an anti-gay agenda in Uganda. In 2012, a Ugandan gay rights group filed a lawsuit against a US evangelist, Scott Lively, in Massachusetts, saying he incited the persecution of gay men and lesbians in Uganda.

If Mr Museveni signs the bill into law it is likely to antagonise the socially liberal Western governments that provide aid to Uganda.

"The United States government cannot stand idly by as a witness to history as the Ugandan government prepares to strip lesbian, gay, bisexual and transgender Ugandans of their human and legal rights," Ruth  Messinger, president of the American Jewish World Service, said in a statement, calling the measure a "draconian law, which is nothing less than an act of state-sanctioned hate."

The New York-based Centre for Constitutional Rights said in a statement that if Mr Museveni signed the bill, it would "place the lives of countless Ugandans at risk." The proposed measure "had already intensified the climate of hatred and persecution" against gay men and lesbians in Uganda, the rights group said.

"The international community has a legal and moral obligation to prevent this law from being implemented," the group said.

But opposition from abroad often only stiffens the resolve of African governments, which oppose what they perceive to be meddling from foreigners, especially former colonial powers.

"Hey guys supporting homosexuals take it easy Uganda is a sovereign country," Mr Opondo said in a subsequent tweet.

The proper course for opponents of the law, he added, is to challenge it in court.

New York Times