LONDON — The Ugandan Parliament announced Friday that it had approved legislation imposing harsh penalties on gay people, including life imprisonment for what it called “aggravated homosexuality,” effectively brushing aside previous objections to antigay legislation from outside powers, including President Obama.

In addition to prohibiting “any form of sexual relations between persons of the same sex,” the law seemed to echo Russia’s so-called gay propaganda law, criminalizing “the promotion or recognition” of homosexual relations “through or with the support of any government entity in Uganda or any other nongovernmental organization inside or outside the country.”

Specifically, the law — officially the Anti-Homosexuality Bill 2009 — provides for a 14-year jail term for a first conviction and “imprisonment for life for the offense of aggravated homosexuality,” a Parliament announcement said.

“The bill aims at strengthening the nation’s capacity to deal with emerging internal and external threats to the traditional heterosexual family,” it said, quoting a Parliament committee.