Addressing religious, military and political leaders, Supreme Leader Ayatollah Ali Khamenei, Iran's top authority, prayed for "the success of a worthy person".
Symbolising the endorsement, Khamenei handed over the presidential mandate to Rouhani. The leader kissed Rouhani on the cheek and the new president kissed the leader on his shoulder, a sign of supplication.
The mid-ranking Shi'ite cleric is seen as a pragmatist in contrast to Khamenei and his hardline allies, and officials and analysts have cast doubt on his ability to balance their demands and expectations with those of his supporters.
Khamenei once again called for Iran to achieve economic self-sufficiency and build a "resistance economy". He has repeatedly criticized the slow pace of economic recovery since most international sanctions on Iran were lifted last year.
Under Rouhani's watch, Iran reached a landmark deal with six major powers in 2015 under which it agreed to curb its nuclear activities in exchange for the lifting of sanctions which had been in place for a decade.
After being sworn in on Saturday, Rouhani will have two weeks to present his cabinet to the parliament for a vote of confidence.
"The government's aim is to improve Iran's image in the world ... to safeguard people's rights ... to end poverty ... to protect the religious democracy and our people's votes," Rouhani said in a speech at the ceremony.
Rouhani has vowed to open Iran up to international investment and trade but the Islamic Republic insider who has held senior political and military posts since the 1979 Islamic revolution, faces enormous challenges, including deepening political divisions among the country's ruling elite and U.S. President Donald Trump's aggressive Iran policy.