Muhammadu Buhari has been sworn in as Nigeria's president, promising to bring "increased prosperity" to Africa's most populous country.
He is the first opposition figure to win a presidential election in Nigeria since independence in 1960.
"I belong to everybody and I belong to nobody", he told cheering crowds at the inauguration in the capital, Abuja.
He vowed to tackle "head on" the issues of corruption and the insurgency from militant Islamist group Boko Haram.
Mr Buhari, a former military ruler, has taken over from Goodluck Jonathan, who had been in office since 2010.
At the inauguration ceremony at Abuja's Eagle Square - Mr Jonathan handed over the constitution and national flags before Mr Buhari took his oath of office.
In his first speech as president, Mr Buhari reiterated his commitment to tackle Boko Haram, whom he described as "a mindless, godless group, who are as far away from Islam as one can think".
Will Ross, BBC News, Abuja:
As soon as Muhammadu Buhari was sworn in the invited guests in Eagle Square rose to their feet, danced and sang their new president's name. As he was then driven around in an open vehicle, people rushed forward to record the moment on their phones.
This was a time for celebration not just for supporters of the new leader but also for Nigerians who are proud that their country has witnessed this historic transition. By conceding Goodluck Jonathan steered the country away from violence. We will never know how close Nigeria was to the precipice.
Moments after Muhammadu Buhari was sworn in thousands of excited young men ran through the security barriers to Eagle Square and pressed up against the perimeter fence cheered their new leader. It was a stark reminder that so many in Nigeria are expecting change, including jobs, from President Buhari.
As Mr Jonathan is driven away I would not be surprised if he has a sense of relief and feels an almighty weight has just been lifted off his shoulders.
Mr Buhari also announced plans for the Nigerian military's command centre to be moved from Abuja to the strategic north-eastern city of Maiduguri, which is closer to areas where the group operates.
He said Boko Haram could not be said to be defeated without rescuing the more than 200 Chibok girls, whose capture last April sparked a global campaign to bring them back home.
"This government will do all it can to rescue them alive," he said.
Mr Buhari said the Nigerian economy was "in deep trouble", identifying "insecurity, pervasive corruption... and seemingly impossible fuel and power shortages" as key concerns.
The country's power supply crisis was "a national shame", he said, which had brought "darkness, frustration, misery, and resignation" to Nigerians.
Muhammadu Buhari in focus:
- Muslim from northern Nigeria, aged 72
- Military ruler of Nigeria from 1984 to 1985, deposed in a coup
- Seen as incorruptible
- Poor human rights record
- Survived apparent Boko Haram assassination attempt
The president rounded off his speech with a quotation from Shakespeare, before issuing a final rallying call to Nigerians: "We have an opportunity. Let us take it."
Among the guests at the ceremony were US Secretary of State John Kerry and African leaders including Zimbabwe's President Robert Mugabe.