President Olusegun Obasanjo has pledged to reunite Nigeria following disputed elections.
Obasanjo warned he did not have a 'magic wand'
Wearing white robes, he told a crowd of guests invited to a colourful inauguration ceremony in the capital, Abuja, that this would be the first task of his second term.
Mounted policemen in bright red uniforms formed a guard of honour while children performed traditional dances amid tight security.
Mr Obasanjo hopes that this will prove to be the first successful transition from one civilian government to another since the country's independence in 1960.
Mr Obasanjo won a decisive victory in an election held last month, winning almost twice as many votes as his nearest rival.
However, the opposition claims that his victory was achieved through fraud and has challenged the results in court.
Police banned political demonstrations in the run-up to the inauguration but there were some opposition protests in the northern city of Kano on Wednesday.
'Years of destruction'
"I see my initial assignment as president in trying to heal the wounds from the elections," he told the crowd in a strained voice, apparently tired out by campaigning.
He also said it was imperative to stop the influence of religion in politics.
Among the several African leaders present was Robert Mugabe, leader of Zimbabwe, where Mr Obasanjo is trying to mediate in the crisis.
Raise living standards
Stop ethnic, religious violence
High-level representatives from the United States and United Kingdom Governments were also present.
"I, Olusegun Obasanjo, do solemnly swear that I will be faithful and bear true allegiance to the Federal Republic of Nigeria, and that I will preserve, protect and defend the constitution of the Federal Republic of Nigeria," he pledged to cheers and applause.
However, he warned that he did not have a "magic wand" to "put right in a few years the destruction of two decades".
The courts this week rejected a request by opposition leader Muhammadu Buhari to postpone the inauguration.
Opposition groups say Obasanjo's victory is a fraud
International and Nigerian election monitors agreed there had been widespread irregularities during the vote, but none questioned the overall outcome.
For most of the time since independence, the country has been ruled by a series of military dictatorships.
In 1983, General Muhammadu Buhari, who came second to Mr Obasanjo in last month's poll, seized power just three months after the only other elections successfully organised by civilians.
But the BBC's Dan Isaacs in Abuja says there is a growing optimism that although this latest election process was marred in controversy, the democratic process is now firmly entrenched in Nigeria.