LONDON — Brushing aside Western threats and outrage, President Yoweri Museveni of Uganda significantly strengthened Africa’s antigay movement on Monday, signing into law a bill imposing harsh sentences for homosexual acts, including life imprisonment in some cases, according to government officials.

The move came weeks after Mr. Museveni’s Nigerian counterpart, Goodluck Jonathan, took similar steps in his own country, threatening offenders with 14-year prison terms. The Ugandan law seemed even tougher, threatening life terms on charges including “aggravated homosexuality,” meaning homosexual acts with a minor, a disabled person or someone infected with H.I.V.

Africans “never seek to impose our view on others; if only they could let us alone,” Mr. Museveni said, alluding to Western pressure to reject the bill.

He signed the legislation at his official residence at Entebbe, near the capital, Kampala, in front of government officials, journalists and a team of Ugandan scientists who had said they found no genetic basis for homosexuality — a conclusion that Mr. Museveni cited in support of the new law.