ACCRA (Reuters) - 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 future of Africa is in the hands of Africans,” Obama told a crowd of several thousand, including dancers and drummers, seeing him off after the visit of less than 24 hours.

Addressing the young people of Africa, Obama said: “You have the power to hold your leaders accountable and to build institutions that serve the people.”

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.

“ENCOURAGEMENT”

“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.

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.

Slideshow ( 17 images )

“Obama’s visit was a defining moment for Africa,” said Mohamed ibn Chambas, who heads regional bloc ECOWAS.

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

“This encourages us also to sustain the gains that we have made in our democratic process,” said Ghanaian President John Atta Mills, elected in a transparent election that contrasted with stereotypes of chaos, coups and corruption in Africa.

Slideshow ( 17 images )

Reforms in the cocoa and gold producing country, set to begin pumping oil next year, helped bring unprecedented investment and growth before 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.”

But expectations were anchored in reality.

“I am not under any illusion that he’s coming to solve our problems in one go,” said Janet Ashiboe, 42, a market trader.

Obama made a trip by helicopter to Cape Coast Castle, a former depot of the transatlantic slave trade and a reminder of one of the darkest chapters in African and American history.

“As painful as it is, I think that it helps to teach all of us that we have to do what we can to fight against the kinds of evils that sadly still exist in our world, not just on this continent but in every corner of the globe,” a somber-looking Obama told reporters at the white-washed fort.

Although Obama’s ancestors were from Kenya, his wife Michelle is descended from slaves shipped from Africa. Obama, his wife and their two daughters left Accra to return to Washington.