DUBAI (Reuters) - Iran's nuclear deal with world powers on Tuesday marks a triumph for President Hassan Rouhani, an establishment insider who staked his reputation on engaging pragmatically with the West and had to see off challenges from conservative factions.
But more battles lie ahead. He must now justify the high expectations of ordinary Iranians desperate for the end of sanctions to bring better living standards, and of the social reformists who have yet to see much in return for the votes they gave him, as conservatives fight to keep the status quo.
As Iran's negotiating team crisscrossed the globe to seal the nuclear deal, the 66-year-old cleric worked tirelessly at home to keep up support for an agreement and convince all sectors of Iranian society that it was in their interests.
"We want the nation to be happy and productive, to have a bright economy and social welfare -- and to have (uranium) centrifuges too," he told a rally in the northeastern city of Bojnurd last month.
The bulk of sanctions on Iran will remain in place until United Nations inspectors confirm Tehran's compliance with the terms of the agreement. Hardliners are expected to use this chance to accuse the president of making too many concessions.
Iran's conservative-dominated parliament, alongside elements of the judiciary, armed forces and clerical establishment, strongly opposed making any meaningful concessions, and will seize on any perceived abuses by U.N. inspectors or Western powers in the coming months.
Rouhani has so far insulated himself from hardline factions largely by keeping the support of Supreme Leader Ali Khamenei, who has cautiously backed the talks as a way to revive an economy that was being slowly strangled by sanctions.
Ordinary Iranians now hope above all to see investment pour in, jobs created and the price of basic goods, utilities and rents stabilised in exchange for curbing the nuclear programme.
But many observers believe Khamenei and other hardliners may take a firmer line with Rouhani after the deal, fearing the president might become too powerful if his faction fares well in elections next year.
"Now that the president has outmanoeuvred his rivals on the nuclear front, they are likely to try to block him on other fronts," said Ali Vaez, senior Iran analyst at the International Crisis Group.
"The political establishment might feel compelled to compensate the hardliners by giving them a freer hand on socio-cultural issues."
And that will be a problem for Iran's reformists, who helped Rouhani to a landslide election win in 2013 after the Guardian Council, a clerical body that oversees political processes, barred reformist candidates from standing.
Rouhani appeared the most likely of the approved candidates to deliver social or political liberalisation, but has done little to justify those hopes. Rouhani suggested on his campaign that two leading reformists who contested the previous election could be freed within a year, but both remain under house arrest.
"There are very high expectations of Rouhani, and there is broad frustration that two years have passed and he hasn't done anything," said Hadi Ghaemi, executive director of the International Campaign for Human Rights in Iran, a New York-based advocacy group.
"He has put all his political capital in foreign policy and the negotiations."
Rouhani is, ultimately, very much a part of the establishment. He went into exile before the revolution with Ayatollah Ruhollah Khomeini, the first Supreme Leader, and was later secretary of the Supreme National Security Council for 16 years. He also served as Iran's top nuclear negotiator.
Yet with an eye on next year's elections to parliament and the Assembly of Experts, a clerical body charged with appointing and supervising the Supreme Leader, and the presidential election in 2017, Rouhani needs to keep reformist voters onside.
He can point to his efforts to rein in the judiciary, elements of which can act capriciously. Last month, he called for greater transparency in the application of the law, and a clear definition of political crimes.
"Our judicial system must be transparent for everyone," he said. "We can see that a single law can have many interpretations, and the judge can make his own presumptions when he delivers a verdict."
Rouhani also criticised the judiciary for cancelling concerts that had received licences from the government, and in April he told a gathering of police commanders that their duty was to enforce only the law, not Islam.
"Domestic social issues are definitely a priority for Rouhani," said Kevan Harris, an assistant professor of sociology at the University of California, Los Angeles, (UCLA) who focuses on Iran.
"One of the patterns that we can expect to occur is a relative opening of discussion before the election ... the question is how the various sides will take advantage of that."
But even on a relatively minor issue such as the cancellation of concerts, the head of the judiciary, Ayatollah Sadeq Larijani, made a point of contradicting Rouhani.
It is a long way from that to the human rights challenges listed in a United Nations report in March: frequent executions of prisoners including political activists and juveniles; routine imprisonment of journalists; frequent violations of women's and minority rights.
"Rouhani has pointed out a clear need for reform, but we should measure his progress on concrete actions," Ghaemi said. "The real question is: will he capitalise on his popular support?"
Editing by Kevin Liffey