Mahmoud Ahmadinejad faces daunting challenges as he begins his second term
By Jon Leyne
BBC Tehran correspondent
After the turmoil of the last two months, it was a moment when Mahmoud Ahmadinejad could attempt to restore his dignity.
This time the drama was neatly choreographed as the oath was administered.
The hugs, handshakes and kisses all in proper order, unlike the awkward moment on Monday when he was officially endorsed by the supreme leader, Ayatollah Khamenei.
But in front of the president were a number of empty seats, as some MPs and other senior figures boycotted the ceremony.
The British and European ambassadors did attend, but Western governments declined to send messages of congratulations.
And, as his second term begins, Mr Ahmadinejad faces an increasing series of problems.
There are the demonstrations on the streets.
For the moment they do not look big enough to unseat him, but by their sheer persistence, the protesters are rattling the government, keeping it off balance.
And there is always the possibility of a much bigger explosion of protests if the government tried to arrest the opposition leaders, or perhaps when students return to university in October.
The split at the heart of the Iranian political establishment was confirmed by the boycott of the ceremony by all three opposition presidential candidates, Mir Hossein Mousavi, Mehdi Karroubi, Mohsen Rezai, as well as two former presidents.
But Mr Ahmadinejad will be equally worried about the growing number of conservative former allies he has antagonised, before and after the election.
He has two weeks to present a new cabinet to parliament for approval and, even though parliament is made up almost entirely of fellow conservatives, if past form is a guide it could be a tough battle.
Then there is the economy. It has been almost forgotten in recent weeks, but the disastrous state of Iran's economy is one of the big reasons for Mr Ahmadinejad's unpopularity in the country.
Many lawmakers - as well as foreign envoys - did not attend the ceremony
The government staved off problems before the election, but now they could be compounded by a collapse in confidence as the administration struggles to stay in control.
And this is about the time the recent collapse in oil prices will start working its way through to government finances.
Then, of course, there is foreign policy - Iran is under growing pressure from the West to answer President Barack Obama's offer of new talks on the nuclear issue.
Mr Ahmadinejad's natural response is one of defiance.
But that might risk alienating China and Russia, and that could mean new sanctions to add to Iran's current economic woes.
So Mr Ahmadinejad faces a daunting series of challenges as he tries to resume business as normal.
Above all, he faces a crisis of legitimacy. The doubts concern not just his election victory but increasingly the whole Islamic system under which Iran is governed.
For the president it will be an interesting four years ahead - if he survives that long.