(CNN) -- After years of controversy, the Ugandan parliament has passed a bill that punishes certain acts of homosexuality with life in prison.
A Ugandan lawmaker first introduced the bill in 2009, sparking worldwide condemnation for tough measures that included the death penalty.
It was briefly shelved amid the backlash. At the time, some European nations threatened to withdraw aid to Uganda, which relies on millions of dollars from the international community.
Before its passage Friday, parliament adjusted the death penalty clause to life in prison for "aggravated homosexuality." It includes acts where one person is infected with HIV, "serial offenders" and sex with minors, Amnesty International said.
In cases where one has HIV, the punishment applies even when the sex is consensual or protected.
"Ugandans have been anxiously waiting for this bill. This day will be a good day for all Ugandans," said Benson Obua Ogwal, a member of parliament for Moroto.
The bill also proposes years in prison for anyone who counsels or reaches out to homosexuals, a provision that would ensnare rights groups and others providing services to lesbians, gays, bisexual and transgender people.
"The knock-on effect of passing this bill will reach far beyond gay and lesbian people in Uganda, impeding the legitimate work of civil society, public health professionals and community leaders," said Aster van Kregten, deputy Africa director at Amnesty International.
Homosexuality is illegal in most African countries, where sodomy laws were introduced during colonialism. In Uganda, homosexual acts are punishable by 14 years to life in prison, according to rights activists.
But lawmakers in the conservative nation sought tougher legislation, saying Western lifestyle risks destroying Ugandan family units.
"This is a piece of legislation that is needed in this country to protect the traditional family here in Africa, and also protect the future of our children," David Bahati, the lawmaker who first introduced the bill, said last year. "Every single day of my life now I am still pushing that it passes."
Rights groups urged President Yoweri Museveni to veto the bill. To become law, it requires his signature within 30 days.
CNN's Joseph Netto contributed to this report