Moderates backing Iranian President Hassan Rouhani made significant gains in last week’s elections, winning all 30 of the seats in parliament for representatives from Tehran. Notably, even Gholam Ali Haddad-Adel, a conservative leader and former speaker of parliament, failed to secure a seat from Tehran. Conservatives and independents did better further out from the capital; in some instances, moderates’ successes were due to informal alliances with moderate conservatives. Overall, the results appear to be an electoral endorsement of Mr. Rouhani’s moderate policies: the nuclear deal he reached with world powers and the resulting rollback of economic sanctions on Iran; his receptivity to foreign investment; and his attempts to ease restrictions on Iranians (with limited results so far).

In the 88-member Assembly of Experts, the all-clerical body charged with electing the next supreme leader, President Rouhani and former President Akbar Hashemi Rafsanjani, an ally, were among the top vote-getters of candidates in the capital. Conservatives will continue to dominate the assembly, but the poor finish of several prominent hard-liners is striking:Ahmad Jannati, a powerful octogenarian and arch-conservative head of the Council of Guardians, barely squeaked in; Mohammad Taqi Mesbah-Yazdi, a theologian of the hard right, and Mohammad Yazdi, the current head of the Assembly of Experts, failed to win seats.

Having a substantial bloc of moderates/reformists and like-minded independents in the new parliament is expected to strengthen Mr. Rouhani’s hand in some areas but will make little difference in others. The president will have more freedom in choosing his Cabinet; his ministers are less likely to be harassed or face calls for resignation by members of the legislature. He can more easily advance his economic agenda, including increased privatization, fewer restrictions on business, and perhaps a more inviting and secure environment for foreign investors. Mr. Rouhani is likely to have greater scope for opening up the social sphere, giving more freedom to the young, and protecting women and youths from harassment by the morals police.

Mr. Rouhani had almost no success in opening up the political sphere during his first three years in office. He has little or no control over Iran’s multiple security services: the fearsome intelligence organizations as well as the intelligence/security branches of the Revolutionary Guards and the Basij paramilitary forces. These forces arrest and imprison dissidents and others they do not like with impunity. The judiciary cooperates closely with the security agencies, and the head of the judiciary is named by the supreme leader, so is not controlled by the president. None of this is likely to change in the foreseeable future.

In terms of foreign policy, Mr. Rouhani has, in some ways, set Iran on a new course. Implementation of the nuclear deal has begun, foreign trade is picking up, major economic deals with European countries and firms are in the works, and officials in Tehran and Washington discuss–albeit intermittently–some regional issues. But parliament has almost no say on major foreign policy issues, such as Iran’s role in Syria or Iraq; on Lebanon and Hezballah; or toward Israel and the U.S.

A strong showing of public support in these elections can be expected to strengthen Mr. Rouhani’s hand in general. But when it comes to internal security, human rights, political freedoms, and major foreign-policy issues, the course will not be set by parliament or the president but by the supreme leader and the security agencies and Revolutionary Guard commanders on whom he relies.

The opinions expressed here are solely those of the author.

This article was originally published in The Wall Street Journal's Washington Wire.