Iran's President Hassan Rouhani, after securing a decisive re-election, has pledged to open the country to the world and deliver the freedom its people have yearned for.

Rouhani sealed a second term in office after he won Friday's election with more than 57 percent of the vote. His principlist rival, Ebrahim Raisi, won 38 percent.

"Iran's nation chose the path of interaction with the world, away from violence and extremism," the 68-year-old reformist said in a televised speech on Saturday.

"Today, Iran - prouder than ever - is ready to promote its relations with the world based on mutual respect and national interests," he said.

The election was seen by many as a verdict on Rouhani's policy of opening up Iran to the outside world, including the 2015 nuclear deal that won the country relief from international sanctions in exchange for limits on its contested nuclear programme.

Iran "is not ready to accept humiliation and threat", Rouhani continued.

"This is the most important message that our nation expects to be heard by all, particularly world powers."

Saturday evening saw tens of thousands of his supporters celebrating by pouring into the streets of downtown Tehran, setting off fireworks, and singing and dancing until the early hours of Sunday morning.

"I'm happy and a bit relieved after a month of stress," said 27-year-old Afshin as he joined a large crowd gathered in Vali Asr Square in central Tehran.

READ MORE: Profile - Iran's President Hassan Rouhani

"In the same way we campaigned for him, we will demand he keeps his promises."

Videos on social media showed huge crowds out on the streets across Iran.

Many wore purple ribbons in support of Rouhani as well as the green of the the reformist movement crushed by security forces after a 2009 election, whose leaders have been under house arrest since 2011.

During campaigning, Rouhani had promised to seek their release if re-elected.

Many experts are skeptical that a president can effect a huge change in the country as he is subordinate to the supreme leader, who is chosen by a clerical panel and has veto power over all policies and control over the security forces.

One of the first world leaders to congratulate Rouhani was Iran's ally, Syrian President Bashar al-Assad, who said he looked forward to cooperating "to strengthen the security and stability of both countries, the region and the world".

US Secretary of State Rex Tillerson, whose country has had no diplomatic relations with Iran since 1980, said he hoped Rouhani would use his second term to end Tehran's ballistic missile programme and what he called its network of terrorism.

Iran denies any involvement in terrorism and says its missile programme, which US President Donald Trump recently targeted with new sanctions, is purely for defence purposes.