There was confusion as the Supreme Leader congratulated Mr Ahmadinejad
Senior Iranian political figures appear to have snubbed the formal endorsement of Mahmoud Ahmadinejad as president by Supreme Leader Ayatollah Ali Khamenei.
His predecessors as president, Mohammad Khatami and Akbar Hashemi Rafsanjani, did not attend the ceremony.
Also missing were the two opposition candidates defeated in June's election - that was mired in claims of rigging - Mir Hossein Mousavi and Mehdi Karroubi.
Later, riot police reportedly prevented several opposition protests in Tehran.
After the 12 June election, thousands of Iranians took to the streets in the largest mass demonstrations since the 1979 Islamic Revolution.
Hints of tension
The BBC's Tehran correspondent, Jon Leyne, says public protests have ebbed since, in the face of mass arrests and a strong police presence on the streets.
The BBC was sent video of a purported opposition protest in Tehran on Monday
But Iran's political elite has been in open disagreement about how to move forward and opposition to the president continues to grow, our correspondent adds.
Mr Ahmadinejad will be inaugurated for a second term on Wednesday, and will have two weeks to form a government that must be approved by parliament.
In Monday's ceremony, broadcast live on the state-run Arabic and English TV, but not on the Farsi channels, Ayatollah Khamenei formally gave his backing to Mr Ahmadinejad.
Describing last month's poll as a "golden page" in Iran's political history, he declared the incumbent the victor with more than 60% of the vote.
Jon Leyne Tehran correspondent, BBC News
By endorsing the disputed election victory, Ayatollah Khamenei has tied his political future, and perhaps even the future of the Islamic Republic, to the fate of this controversial president. Today that bond was sealed.
But the leader must already be wondering whether he might need to jettison the president to secure his own future, even though it would cause him enormous political damage.
The real threat to Mr Ahmadinejad could come from his former allies. An increasing number have been expressing doubts about the president's behaviour since the election. As the president attempts to form a new cabinet, and win approval by parliament, his troubles could just be beginning.
"Iranian people have voted in favour of a fight against arrogance, to confront destitution and spread justice," al-Alam TV quoted the Supreme Leader as saying.
Mr Ahmadinejad, 52, accepted a decree from Ayatollah Khamenei, bowing as the Supreme Leader offered his hand.
There was apparent confusion between the two men as the Supreme Leader appeared to offer his hand, only for Mr Ahmadinejad to reach out and kiss his shoulder.
The official Irna news agency later reported that Mr Ahmadinejad had not kissed Ayatollah Khamenei's hand or cheek because he had a cold.
Whatever the reason, the strangely awkward moment was a graphic representation of the sometimes difficult relationship between the two leaders, says our correspondent.
After the ceremony, witnesses said hundreds of people had attempted to hold a demonstration in Vanak Square in the north of Tehran, but that they were dispersed the Revolutionary Guards, the Basij militia and police.
One protester called Maryam told BBC Persian the protest had been peaceful and that they were attacked indiscriminately.
"Plain-clothed officers started attacking people from the middle of the crowd," she said. "People were chased away and many were beaten up. Electric batons and tear gas were being used to displace the crowd."
Splits on show: how Iran's political elite has changed from 2005 to 2009
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.