KAMPALA, Uganda -- Ugandan lawmakers on Friday passed an anti-gay law that punishes "aggravated homosexuality" with life imprisonment.

The bill drew wide condemnation when it was first introduced in 2010 and included the death penalty, but that was removed from the revised version passed by parliament.

Although a provision for the death penalty was removed from the original bill, the law passed Friday sets life imprisonment as the maximum penalty for the new offence of "aggravated homosexuality," according to the office of a spokeswoman for Uganda's parliament.

The bill was introduced to parliament by a lawmaker who argued the law was needed to deter Western homosexuals he accused of "recruiting" Ugandan children.

Homosexuality was already illegal in Uganda under a colonial-era law that criminalized sexual acts "against the order of nature," but the Ugandan lawmaker who wrote the new law argued that tough new legislation was needed because homosexuals from the West threatened to destroy Ugandan families and were allegedly "recruiting" Ugandan children into gay lifestyles.

Ugandan gays disputed this account, saying that Ugandan political and religious leaders had come under the influence of American evangelicals who wanted to spread their anti-gay campaign in Africa. Ugandan gays singled out Scott Lively, a Massachusetts evangelical, and sued him in March 2012 under the Alien Tort Statute that allows non-citizens to file suit in the U.S. if there is an alleged violation of international law.

Lively denied he wanted severe punishment for gays, and has previously told The Associated Press he never advocated violence against gays but advised therapy for them.

Over the years Ugandan gays had come to believe progress was being made in defence of their rights in a country where homophobia is rampant. In 2012 they held their first gay pride parade and have sometimes joined street marches in support of all human rights.

Pepe Julian Onziema, a prominent Ugandan transgender and gay activist, declined to comment when contacted by AP on Friday, saying he needed more time.

Despite criticism of the bill abroad, it was highly popular among Ugandans who said the country had the right to pass laws that protect its children.

Amid international criticism, the bill was repeatedly shelved despite the protests of Ugandan lawmakers. Days before Christmas last year, the speaker of Uganda's parliament, Rebecca Kadaga, threatened to pass the anti-gay law as a "Christmas gift" to all Ugandans.

When the bill was first proposed, President Barack Obama called it "odious."