In a ballot on Friday for parliament an alliance of pro-Rouhani reformists and moderates gained seats, conservative numbers were cut and hardliners who had opposed the nuclear agreement were all but wiped out.
Although the president's allies did not secure a majority in parliament, they made significant gains that are likely to make passing legislation much easier.
A simultaneous election was held for the Assembly of Experts, a powerful clerical body that appoints Iran's supreme leader, Iran's ultimate authority, currently Ayatollah Ali Khamenei.
Why two elections at the same time?
Iran, an Islamic republic since a 1979 revolution toppled the pro-Western monarchy of Shah Mohammad Reza Pahlavi, has some institutions and many officials appointed by the supreme leader, but parliament and the Assembly of Experts are elected directly by the people.
All candidates are vetted by a constitutional watchdog, The Guardian Council, for their loyalty to the state.
Polling for the country's 290 MPs takes place every four years, while the 88 members of the Assembly are elected for eight years -- and this year the two elections coincided.
The Assembly of Experts generally has a low profile, but a long dormant task may be undertaken during its next term if the incumbent Khamenei, who is 76, dies. The assembly would pick his replacement.
Under Iran's system the supreme leader outranks the president and has the final word on major areas of domestic and international policy, setting the country's strategic direction.
What are the main political forces?
There are two major political movements in Iran: reformists and conservatives. The conservative bloc is not monolithic, however: it also has radicals (or ultra-conservatives) and moderates.
Moderates can find themselves aligned with reformists on some policy matters.
Signup to our newsletter and follow us on Facebook and Twitter!
The agreement of July 2015 between the major powers and Iran over its nuclear programme was approved by reformists and moderate conservatives, for example.
Who won? Conservatives or reformists?
There is no clear cut victory for either of the two camps, as none on its own will have a parliamentary majority.
But the allies of reformists and supporters of Rouhani made significant gains and were able to offset the strong influence of conservatives.
Most ultra-conservatives have been sidelined and the government will, in addition to its own supporters, probably be able to rely on the votes of moderate conservatives on some future reforms.
In the last parliamentary elections in 2012, reformists largely boycotted the polls in protest at the disputed 2009 re-election of then president Mahmoud Ahmadinejad and the subsequent house arrest in Tehran since 2011 of reformist leaders Mehdi Karroubi and Mir Hossein Mousavi.
The Assembly of Experts remains dominated by conservatives, but reformists and moderates have had symbolic victories. They partly achieved their main goal -- the voting out of two of the three strong conservative personalities in the assembly, Ayatollah Mohammad Yazdi, its president, and Ayatollah Mohammad Taghi Mesbah-Yazdi, a figure long openly hostile to reformists.
Where does the supreme leader stand?
The supreme leader safeguards the unity of the nation and never officially takes part in partisan fights. But he remains Iran's strongman and his statements and influence are unquestionable.
Without his consent, the nuclear negotiations leading to the accord and the lifting of crippling international sanctions would not have been possible.
The decision was hailed by reformists.
But since the agreement, Khamenei has warned against the "arrogance" of the United States, dubbing it the key player behind risks of economic, political and cultural "infiltration" by foreign powers.
Khamenei's views on "infiltration" and the "arrogance" were widely used by many conservatives during election campaigning.