The 64-year-old former nuclear negotiator, who has committed himself to greater international engagement for Iran which is battling sanctions over its nuclear programme, was administered the oath in Milli Majlis, the Iranian Parliament.
Rouhani was officially endorsed by the supreme leader Ayatollah Ali Khamenei Khamenei yesterday for a four-year term.
"The country needs a national determination to keep its distance from extremism and needs to concentrate on the rule of law," Khamenei had said, endorsing the moderate cleric.
Reflecting warm bilateral ties, Ansari flew into the Iranaian capital by a special plane to represent India at the ceremony.
More From This Section
Ansari was earlier India's ambassador to Iran.
India's representation was upgraded after earlier plans for External Affairs Minister Salman Khurshid to attend were dropped.
Rouhani, who succeeds hardliner Mahmoud Ahmedinijad, had already stoked a controversy when he had reportedly said that Israel is a "wound" on the Muslim world "and needs to be removed". But the remarks were later denied by Iran's state-run TV.
In his first appointment after assuming office Rouhani named Mohammad Nahavandian, a 58-year-old businessman with a doctorate in economics from George Washington University in Washington, as his chief of staff, state-run IRNA news agency reported.
Rouhani in a first address, broadcast live on state television yesterday, said that his new government "will take fundamental steps in elevating Iran's position based on national interest and lifting of the oppressive sanctions.