By Jeff Mason and Daniel Flynn
DAKAR (Reuters) - President Barack Obama, kicking off a long-awaited African tour, lauded a U.S. Supreme Court ruling on gay marriage as a victory for democracy and urged African nations to end discrimination against homosexuals.
In only his second visit to Africa since taking office, Obama hailed the advance of democracy there and said he was looking at ways to extend the AGOA free trade agreement, due to expire in 2015, to create more jobs on the world's poorest continent.
"I see this a moment of great promise for the continent," Obama told a news conference in Senegal's capital Dakar. "All too often the world overlooks the amazing progress that Africa is making, including progress in strengthening democracy."
Flanked by Senegal's President Macky Sall, Obama said the treatment of lesbians and gays in Africa remained "controversial". Homosexuality is illegal in Muslim Senegal.
The U.S. Supreme Court ruling on Wednesday, announced as Obama flew to Senegal aboard Air Force One, made married gay men and women eligible for federal benefits, striking down part of the 1996 Defense of Marriage Act.
"It was a victory for American democracy," Obama said. "At the root of who we are as a people, who we are as Americans, is the basic precept that we are all equal under the law."
However, the court fell short of a broader ruling endorsing a fundamental right of gay people to marry, meaning there will be no impact in the more than 30 states that do not recognize gay marriage.
Human rights group Amnesty International had urged Obama to use his African trip to speak out against threats to gays and lesbians, which it said were reaching dangerous levels on the continent.
Consensual same-sex conduct is a crime in 38 countries in sub-Saharan Africa, with some seeking to enact new laws that increase existing penalties, Amnesty said.
While voicing respect for the diversity of cultures and religions in Africa, Obama - the first African-American president of the United States - called for steps to make homosexuals equal before the law. He compared gay rights in Africa to racial struggles in the United States.
"When it comes to how the state treats people, how the law treats people, I believe that everybody has to be treated equally," Obama said, though he added he had not specifically discussed this with Sall.
SENEGAL "NOT HOMOPHOBIC"
Sall, who won office last year in West Africa's oldest democracy, said there was no persecution of gays in Senegal.
"We are not homophobic," he said "Senegal is a country that respects freedoms. Gays are not persecuted, but for now they must accept the choices of other Senegalese."
Obama was feted by flag-waving crowds on Dakar's streets. During his first term, Obama's only African trip was a one-day stopover in Ghana and many Africans have been impatient for him to make an extended tour of the continent.
Visiting Senegal's Supreme Court, Obama praised the independence of the former French colony's judiciary.
Senegal is pursuing a high-level corruption case against the son of former President Abdoulaye Wade on charges of embezzling up to $1.4 billion during his father's 12-year presidency.
It is also conducting a trial of Chad's ex-dictator Hissene Habre on charges of crimes against humanity - the first time a former leader of one African state has been tried by another.
"Trade and investment around the world increasingly flow to places where there are rules and courts play an important role in that," Obama said, praising Senegal's institutions.
Obama said he had instructed U.S. officials to finalize a new trade and investment pact with the West African regional bloc ECOWAS, which includes economic heavyweight Nigeria.
Washington is also looking to extend the African Growth and Opportunity Act (AGOA) when it expires in 2015. The deal, signed into law by former President Bill Clinton in 2000, slashes customs duties for African countries building free markets.
"I am looking for ways to renew it but also improve it so it can generate more jobs," Obama said.
(Additional reporting by Mark Felsenthal and Bate Felix; Writing by Daniel Flynn; Editing by Andrew Roche)