U.S. President Barack Obama told Africans on Saturday that Western aid must be matched by good governance and urged them to take greater responsibility for stamping out war, corruption and disease plaguing the continent.

Obama delivered the message on his first visit to sub-Saharan Africa since taking office in January as the first black U.S. president. He chose stable, democratic Ghana because he believes it can serve as a model for the rest of Africa.

Fresh from a G8 summit where leaders agreed to spend $20 billion to improve food security in poor countries, Obama spoke of a new moment of promise but stressed that Africans must also take a leading role in sorting out their many problems.

Development depends upon good governance, Obama said in a speech to Ghana's parliament. That is the ingredient which has been missing in far too many places, for far too long. That is the change that can unlock Africa's potential. And that is a responsibility that can only be met by Africans.

In an address that offered the most detailed view of his Africa policy, Obama took aim at corruption and rights abuses on the continent, warning that growth and development would be held back until such problems were tackled.

He said America would not impose any system of government, but would increase help for those behaving responsibly.

The visit has enormous resonance for Africa because of Obama's roots as the son of Kenyan immigrant. He laced his speech with tales of his background and the struggles of his forebears in the face of poverty and colonial rule.

It will give encouragement to those fighting corruption and for democracy, said African affairs commentator Joel Kibazo.

He said it in a way that perhaps other presidents could not because he started by outlining his own connections, said Kibazo, while noting Obama was less specific on promoting good governance than with a $63 billion health spending pledge.

YES, WE CAN

MPs chanted yes, we can before Obama started and the president ended his address with that phrase -- his old campaign slogan. The crowd's response was much warmer than the cordial but mostly chilly reception in Moscow earlier in the week.

The language and cadence of Obama's speech was a mix of church sermon, campaign rally and university lecture.

We like the positive signals that this visit is sending and will continue to send, said Ghanaian President John Atta Mills, elected in a transparent election that contrasted with stereotypes of chaos, coups and corruption in Africa.

This encourages us also to sustain the gains that we have made in our democratic process.

Reforms in the cocoa and gold producing country, set to begin pumping oil next year, helped bring unprecedented investment and growth before the impact of the global financial crisis.

Ghanaians, many dressed in Obama t-shirts, packed into the streets of Accra in hope of glimpsing the president. They clustered around television sets in homes, bars and backyards to follow his words.

The message he gave was covering the ways in we should change our lifestyles. I believe when we do that we will prosper, said engineer Joseph Aboagye. We need to change.

Thousands of people, some waving tiny U.S. flags, lined the streets of Cape Coast to greet Obama as his motorcade rolled from the helicopter landing zone to Cape Coast Castle, a former depot of the transatlantic slave trade.

Although Obama's family connections are in Kenya, his wife Michelle is descended from slaves shipped from Africa. They and their two daughters will spend less than 24 hours in Ghana before returning to the United States.