Hassan Rouhani has won a clear victory to a second term as Iran’s president. The turnout in Friday’s election was close to 73 percent, with the incumbent taking some 56 percent of the over-40 million votes cast. Turnout in the last election in 2013 was roughly the same. But that year, Rouhani won only 50.7 percent of the vote.

Still, the significance of this election is not that Rouhani won, but what he did in order to win. This was because, as I learned in discussions with those close to his campaign, in the weeks leading up to the election, his victory was no certainty.

Many American observers assumed the election would be a referendum on the nuclear deal, and that Rouhani would coast to victory. But, for the most part, that was not the case. Unlike in the U.S. presidential campaign, none of the Iranian candidates threatened to rip up the deal. Even the most hardline candidate said that there was no going back on its terms.

The election came at a critical time. The region that surrounds Iran is in turmoil. Its neighbors are increasingly hostile toward the country, and are determined to limit its role in Syria, Iraq, and Yemen. Although there have been no glitches in implementing the nuclear deal, Congress is still talking of scuttling it, and the Trump administration may be set on a path to greater confrontation with Iran. Iranians are worried about unemployment and inflation, pollution and water shortages. They worry about the future.

At the outset, Rouhani was too centrist to excite the millions who had animated the Green Movement of 2009—reformist and secular Iranians who want real change. So to win, and to win big, he had to run an aggressive, attention-grabbing campaign. He addressed issues Iranians cared about in ways that broke taboos and crossed political red lines. And he promised to lift social restrictions and change Iranian politics and foreign affairs in ways that put him on a collision course with the country’s clerical establishment and security forces. This was not just a simple reelection, or a vote for continuity; it wound up as a bold political maneuver and a significant turning point for Iran.

Rouhani’s conservative challengers ran a better campaign than most expected. The well-financed, well-organized conservatives also ran on a powerful populist message that appealed to the legions of poor people whose lives have been unaffected by the high drama of the nuclear deal. They questioned Rouhani’s management of the economy, and why he had been unable to secure the economic benefits he had promised would follow the nuclear deal. They claimed they could better protect Iran’s interests abroad and address its problems at home. The conservatives had a point: the economy had improved but continued to sputter, and its benefits had failed to accrue to the poor. And Rouhani was at a loss to explain why the nuclear deal had fallen short.

Affluent Iranians, who stand to gain the most from the opening of Iran’s economy to the world and relaxation of social restrictions, liked Rouhani but did not believe he would be a change agent. They had welcomed the nuclear deal but were not convinced that it would deliver the economic benefits Rouhani had promised. Moreover, during his first term as president, he had not tackled political reform. Rouhani would have been in trouble if affluent and moderate Iranians did not vote. To win, he needed a high turnout, and the excitement of those who thought nothing would change whether or not they voted.

Early in the campaign, it became clear that Rouhani was in trouble. His conservative challengers did well in the first of two widely viewed live presidential debates by attacking his record. More importantly, they spoke to average Iranians’ economic woes, which polls had found to be by far their main preoccupation.

Rouhani had to change. Running as a moderate who had begun to bring Iran back into the international community would not get him reelected—he had to promise more. He suggested that it was possible to get rid of additional sanctions on Iran, even those connected to its missile program, terrorism, and regional mischief. Declaring that he would challenge Iran’s ruling establishment to talk to the United States about the gamut of issues that have defined Iran’s regional policies was bold. But even that was not enough to rouse the 70-percent turnout he would need to win. He needed the votes of secular and reformist Iranians, the ones who had voted in droves for the reformist President Mohammad Khatami, and poured into the streets during the Green Movement. But those Iranians were not moved by his record of moderation and lack of economic growth.

With polls showing his campaign in trouble, in the last two weeks of the campaign Rouhani reinvented himself as a full-fledged reformist. During the debates and at large rallies, he spoke openly about alleged corruption at the highest levels, involving multi-billion dollars deals with the Revolutionary Guards. He chastised the country’s powerful judiciary, and by implication, its titular head, the supreme leader, for failing to prosecute such blatant cases of corruption. He accused his conservative rival, Ebrahim Raisi, of “having done nothing other trials and executions,” of unjustly prosecuting fellow clerics, and, most controversially, of ordering mass execution of political prisoners in 1988—referring to a purge ordered by the Revolution’s leader, Ayatollah Khomeini—an embarrassing public acknowledgement of human-rights abuses and an indictment of the ruling order, coming from the country’s sitting president.

Rouhani was explicit in addressing demands for political and cultural freedoms, even talking of freeing popular leaders of the Green Movement who have languished under house arrest since 2009. At his rallies, he surrounded himself with reformist leaders and activists who addressed large crowds about fundamental reforms, and openly criticized the security establishment and its human-rights violations. In a direct challenge to conservatives, he took a group of artists and singers to a rally in the city of Mashad, Raisi’s base. Some of those who sang at his rally had been banned from performing only weeks before by the city’s clerics.

Now, Rouhani has changed the dynamics of Iranian politics by openly speaking truth to power and legitimating public criticism of the institutions and leaders of the Islamic Republic. He jolted the Iranian electorate across the political spectrum, and persuaded cynical Iranians to vote. Most importantly, he revived the Green Movement that security forces have suppressed for close to a decade at great cost. This was a risky maneuver, which could have provoked the supreme leader. But the reaction did not come, emboldening Iranians daring to hope. Rouhani triumphed when he made it clear that he is no longer merely the moderate bridge between hardline conservatives and eager reformists.

President Donald Trump has not recognized the significance of the Iranian elections, as was evident from his speech in Saudi Arabia yesterday. Trump called on Muslims everywhere to rid their communities of extremism, and to embrace the promise of growth and prosperity. To be sure, Iran still poses serious security challenges to U.S. interests in the Middle East. But the election made clear what Iranian voters want: economic growth and engagement with the world. And that is what Rouhani has promised them.

In the years ahead, Rouhani is bound to face stiff resistance from conservative clerics and the Revolutionary Guards, whom he took to task during the presidential campaign. But to keep the people on his side, he will have to take risks, with the encouragement and rewards of the United States and its allies—economic and diplomatic engagement—when he does. That cannot be achieved by escalating tensions and confrontation. Washington needs more than a U.S.-Saudi-led containment strategy if it is to take advantage of this moment in Iran.