Mr Obama added his voice to a chorus of criticism from the US and Europe
US President Barack Obama has criticised as "odious" proposed anti-homosexuality legislation in Uganda.
The bill calls for long jail terms or the death penalty in some cases of homosexual intercourse.
It is "unconscionable to target gays and lesbians for who they are," he told politicians and religious leaders at a prayer breakfast in Washington.
Homosexual acts are already illegal in Uganda and punishable by up to 14 years in prison.
The bill would raise that penalty to life in prison.
It also proposes the death penalty for a new offence of "aggravated homosexuality" - defined as when one of the participants is a minor, HIV-positive, disabled or a "serial offender".
For "serial offenders", HIV-positive "offenders", or those engaging in homosexual activity with a minor or disabled person
Life in prison
Seven years in prison
For helping, counselling, or encouraging a person to engage in a homosexual act
The bill has already been widely criticised in Europe and the United States.
"We may disagree about gay marriage," Mr Obama told the annual National Prayer Breakfast, "but surely we can agree that it is unconscionable to target gays and lesbians for who they are, whether it is here in the United States or... more extremely, in odious laws that are being proposed more recently in Uganda."
Uganda's President Yoweri Museveni has distanced himself from the bill, saying it did not represent the views of his government.
Two weeks ago its sponsor, David Bahati, told a Ugandan newspaper he was willing to "amend some clauses".
The cabinet has set up a committee to look at his proposals.