DUBAI/LONDON (Reuters) - Iranian President Hassan Rouhani rejected his foreign minister’s resignation as “against national interests” on Wednesday, bolstering a moderate ally who has long been targeted by hardliners in factional struggles over the 2015 nuclear deal with the West.

Foreign Minister Mohammad Javad Zarif, a U.S.-educated veteran diplomat, announced his resignation on Monday in what an aide said was anger at being excluded from meetings that day with Syria’s president, who was visiting Tehran.

Two days later, he was back with his position strengthened by the president’s endorsement as well as a chorus of support from moderate lawmakers, a senior Revolutionary Guards commander and, implicitly, Supreme Leader Ali Khamenei.

In a letter published by state news agency IRNA, Rouhani told Zarif:

“As the Supreme Leader has described you as a ‘trustworthy, brave and religious’ person in the forefront of resistance against widespread U.S. pressures, I consider accepting your resignation against national interests and reject it.”

Senior Revolutionary Guards commander Qassem Soleimani said Zarif, who helped craft the pact that curbed Iran’s nuclear program in return for sanctions relief, was the main person in charge of foreign policy and he was supported by Khamenei.

The support came at a time when the clerical establishment is in a vulnerable position amid growing pressure from the United States, and so in need of promoting unity and keeping the reform wing on its side.

Iranian leaders reached the conclusion that Washington wants regime change after U.S. President Donald Trump withdrew from the nuclear deal in May last year.

In many of his speeches at the time Khamenei stressed that unity is paramount, and that remains his position as Tehran faces reimposed sanctions.

PROTESTS

Discontent with sky-rocketing inflation and unemployment exacerbated by sanctions have triggered waves of protests. Iranians who were hoping the nuclear deal would bring relief are now calling for Rouhani and clerical leaders to step down.

Zarif’s sudden resignation after months of pressure from hardliners was prompted by his indignation of being excluded from meetings in Tehran between top Iranian officials and Syrian President Bashar al-Assad, an aide said.

Soleimani, who was present at both meetings, said Zarif’s absence was the result of a “bureaucratic” mistake, and there was no intention to exclude him.

A regional official with knowledge of Iranian affairs said that the foreign ministry and the Quds Force - the extraterritorial branch of the Revolutionary Guards that Soleimani commands - had conflicts of opinion over Syria.

The Quds Force focused heavily on Syria, the official said. “This is why Qassem Soleimani is the one in direct relationship with Bashar al-Assad while Zarif came only once to Syria during the seven years of crisis.”

However, apparently to ease the tensions with Zarif, Assad invited him to visit Damascus, according to IRNA, and Zarif spoke with his Syrian counterpart Walid Mouallem by phone to follow up on Assad’s trip to Tehran, Syrian state news agency SANA said on Wednesday.

Zarif also spoke on phone with his Pakistani counterpart, Shah Mahmood Qureshi, and offered mediation between India and Pakistan, after rising tensions between the two countries.

FILE PHOTO - Iranian President Hassan Rouhani (R) and Foreign Minister Mohammad Javad Zarif attend a meeting with Muslim leaders and scholars in Hyderabad, India, February 15, 2018. REUTERS/Danish Siddiqui

“Zarif wanted to resign for a long time and actually he tried several times in the past. But for many reasons, including lack of a replacement, his attempts failed,” said a senior official.

“I believe that is why Zarif decided to go public and resign. It was a cry for help. To tell officials and people that his hands were tied.”

Zarif’s departure would have deprived Iran of its most skilled diplomat, a patient negotiator able to strike a landmark deal with often hostile Western powers.

Hardliners also need him to work with countries such as India and China to find sways to ease the impact of sanctions.

“Zarif is too valuable for the Iranian system to let him go at a time when his diplomatic skills are needed more than ever,” said Ali Vaez, director of the Iran project at Crisis Group.

The foreign minister’s knowledge of the West - gained during years of studying in the United States and then representing Iran at the United Nations - helped him build a rapport with American officials despite decades of animosity between Washington and Tehran.

But after Trump abandoned the nuclear deal and reimposed U.S. sanctions, he came under heavy criticism from opponents who accused him of selling out his country.

POLITICAL AMMUNITION

It was unclear whether Zarif’s resignation announcement, and the expressions of support which followed, were orchestrated. But allies said the last two days’ events would give him political ammunition against hardliners.

“There is no one to replace Zarif as the foreign minister. And the establishment knows that,” said Zarif’s ally, speaking on condition of anonymity.

Khamenei, who stays out of day to day politics, has not publicly commented on Zarif’s resignation. But it is almost certain that Rouhani would have needed a green light from the man with ultimate authority in Iran.

Zarif’s move thrust the schism between Iran’s hardliners and moderates into the open, effectively challenging Khamenei to pick a side.

Zarif gave no specific reasons for his resignation. But allies said he had quit after coming under increasing pressure over the nuclear deal and other issues.

On Wednesday, Zarif thanked Iranians for their support. “As a modest servant I have never had any concern but elevating the foreign policy and the status of the foreign ministry,” he said in an Instagram post.