ENTEBBE, Uganda -- Uganda's president on Monday signed a controversial anti-gay bill that has harsh penalties for homosexual sex, saying the bill is necessary because "arrogant and careless Western groups" had tried to "recruit" Ugandan children into homosexuality.

President Yoweri Museveni signed the bill at his official residence in an event witnessed by government officials, journalists and a team of Ugandan scientists whose report -- which found that there is no genetic basis for homosexuality -- Museveni has cited as his reason for backing the bill.

"We Africans never seek to impose our view on others. If only they could let us alone," he said, talking of Western pressure not to sign the bill.

Get Breaking News Delivered to Your Inbox

Government officials applauded after he signed the bill, which was influenced by the preachings of some conservative American evangelicals. In its original form the bill called for the death penalty for some homosexual acts. That penalty was removed from the legislation following an outcry of international criticism.

The new law calls for first-time offenders to be sentenced to 14 years in jail. It also sets life imprisonment as the maximum penalty for a category of offenses called "aggravated homosexuality," defined as repeated gay sex between consenting adults as well as acts involving a minor, a disabled person or where one partner is infected with HIV.

The bill is widely popular in Uganda, but international rights groups have condemned it as draconian in a country where homosexuality is already criminalized. Some European counties threatened to cut aid to Uganda if the measure is enacted, and U.S. President Barack Obama warned that signing the bill would "complicate" this East African country's relationship with Washington.

In signing the bill, Museveni said he had previously thought homosexuality was merely "abnormal" sexual behavior that some people were born with - the reason he once was opposed to harsh penalties against gays. Now he said he is convinced that it is a choice made by individuals who may try to influence others. Africans are "flabbergasted" by homosexual behavior, he said.

The bill was introduced in 2009 by a lawmaker with the ruling party who said the law was necessary to deter Western homosexuals from "recruiting" Ugandan children. Ugandan gays challenged this account, saying the country's political and religious leaders were influenced by conservative U.S. evangelicals who spread their anti-gay agenda in Africa.

Pepe Julian Onziema, a prominent Uganda gay activist, said he was disappointed that Museveni signed the bill without taking time to talk to the people targeted by the law: Ugandan homosexuals.

"The president is making this decision because he has never met an openly gay person. That disappoints me," he said.

Some in Uganda's gay community had repeatedly tried and failed to meet with Museveni, he said.

Museveni, whose popularity has been fading amid criticism that he wants to rule for life, has faced pressure from the ruling party to sign the anti-gay measure.

Some critics believe Museveni is signing the bill in hopes of galvanizing political support within his party, the National Resistance Movement, ahead of an upcoming meeting that is expected to endorse him as the party's sole choice in the next presidential election in 2016, when he will have been in power for 30 years.