US President Barack Obama, on his first trip to sub-Saharan Africa since taking office, has said Africa must take charge of its own destiny in the world.
Mr Obama also told parliament during his one-day stay in Ghana that good governance was vital for development.
Major challenges awaited Africans in the new century, he said, but vowed that the US would help the continent.
The US president's trip comes at the end of a summit of eight of the world's most powerful nations, held in Italy.
Ghana was chosen as the destination for the president's visit because of its strong democratic record.
"We wanted to make sure to come to an African country after the G8 and after my business in Moscow to emphasise that Africa is not separate from world affairs," Mr Obama said after meeting President John Atta Mills in the capital, Accra.
"What happens here has an impact everywhere," he said.
Speaking to parliament shortly after that meeting, Mr Obama wore a broad grin as he was greeted at the podium by a series of rousing horn blasts from within the chamber.
Development depends upon good governance. And that is a responsibility that can only be met by Africans
US President Barack Obama
"Congress needs one of them," he joked, before turning to more serious matters.
"I have come here to Ghana for a simple reason," the US president said: "The 21st Century will be shaped by what happens not just in Rome or Moscow or Washington, but by what happens in Ghana as well."
Delivering a message that "Africa's future is up to Africans", Mr Obama conceded that the legacy of colonialism had helped breed conflict on the continent.
"But the West is not responsible for the destruction of the Zimbabwean economy over the last decade, or wars in which children are enlisted as combatants," he added.
He praised Ghana's own progress, governance and economic growth, saying Ghana's achievements were less dramatic than the liberation struggles of the 20th Century but would ultimately be more significant.
"Development depends upon good governance," Mr Obama told legislators. "That is the ingredient which has been missing in far too many places, for far too long.
"And that is a responsibility that can only be met by Africans."
'Yes you can'
Expanding on his message, Mr Obama said four key areas were critical to the future of Africa and of the entire developing world, citing democracy, opportunity, health and the peaceful resolution of conflict.
Andrew Harding, BBC News, Accra
The speech has gone down extremely well. This is a country that has been enormously proud to play host to Mr Obama and referred to him as a brother. People say endlessly that he is part of the family and they are expecting a great deal of him.
It was a very broad-ranging speech but Mr Obama has an ability because of his heritage, his Kenyan father, to reach out and speak to Africans in a way that I think most foreign leaders would find very difficult.
There are very few barriers for Mr Obama in this conversation that he is trying to initiate with Africans and I think that this speech will have ticked many, many boxes.
This is Mr Obama trying to link Africa into the international community. He hailed Ghana's democratic society, calling for strong parliaments, honest police, independent judges and a free press across Africa.
However, there were some blunt words directed at other countries, many of which have been undermined by despotic leaders and corrupt politicians.
"Africa doesn't need strongmen, it needs strong institutions," Mr Obama told his audience.
"No person wants to live in a society where the rule of law gives way to the rule of brutality and bribery. That is not democracy, that is tyranny."
He pledged to continue strong US support for public healthcare initiatives in Africa, and called for sensible use of natural resources such as oil in the face of the threat of climate change.
"Africa is not the crude caricature of a continent at war," Mr Obama added. "But for far too many Africans, conflict is a part of life, as constant as the sun. He described wars as a "millstone around Africa's neck".
"You have the power to hold your leaders accountable, and to build institutions that serve the people," Mr Obama said, describing freedom as Africa's "inheritance" and urging the continent to beat disease, end conflict and bring long-lasting change.
In an echo of his presidential election campaign, he drew his speech to a close with a version of his trademark slogan: "Yes you can," he told the gathered legislators.
On the streets of Accra, many billboards welcoming Barack Obama have been erected, including one showing an image of the president and wife with the words: "Ghana loves you".
People have poured into Accra for a glimpse of the president during his 24-hour stay in Ghana.
But security is tight for the president's visit, and few ordinary Ghanaians will have the chance to glimpse the first African-American President of the United States.
Barack Obama's speech was welcomed by Ghanaians of all ages
Mr Obama is expected to visit the Gold Coast Castle, a seaside fortress converted to the slave trade by the British in the 17th Century. He will be accompanied by his wife, Michelle, a descendant of African slaves.
Mr Obama arrived in the capital late on Friday, fresh from the G8 summit in Italy where heads of state agreed on a $20bn (£12.3bn) fund to bolster agriculture - the main source of income for many sub-Saharan Africans.
The visit to the slave fort will be a poignant moment for the country's first African-American president and for his wife Michelle, whose ancestors are believed to have come from West Africa.