Iran's President Hassan Rouhani has rejected the resignation of his Foreign Minister, Mohammad Javad Zarif.

In a letter, Mr Rouhani praised Mr Zarif's record and said: "I think your resignation is against the country's interests and I do not accept it."

Mr Zarif offered to resign on Monday, saying he hoped to allow his ministry to reclaim its "proper statutory role".

His role negotiating the landmark 2015 nuclear deal with world powers exposed him to sharp criticism from hardliners.

Many hardliners opposed the decision to accept limits on the country's nuclear activities in return for the lifting of crippling sanctions.

Pressure on Mr Zarif grew last year after US President Donald Trump abandoned the deal and reinstated US sanctions targeting Iran's oil and banking sectors.

Why did Mr Zarif offer to resign?
Mr Zarif initially gave no explanation.

"I would like to sincerely apologise for not being able to continue my service and for all my shortcomings during my service," he wrote on Instagram on Monday night.

On Tuesday morning, he urged fellow diplomats not to follow his lead and suggested that he had resigned because he felt he had been sidelined.

"I hope my resignation will act as a spur for the foreign ministry to regain its proper statutory role in the conduct of foreign affairs," he said.

He was also quoted by the centrist newspaper Jomhuri Eslami as saying in an interview that political infighting was hampering the foreign ministry's work.

"The deadly poison for foreign policy is for foreign policy to become an issue of party and factional fighting," he said.

Minister 'left with no credibility'
By Kasra Naji, BBC Persian

Mr Zarif's exclusion from top-level meetings in Tehran on Monday during the previously unannounced visit of Syrian President Bashar al-Assad was the final straw.

When photos were released showing Mr Assad attending talks with President Rouhani and Supreme Leader Ayatollah Ali Khamenei, Mr Zarif saw them as a new low for his ministry's role in overseeing Iran's foreign policy.

He wrote in a message to a reporter for a reformist newspaper that that the pictures had left him with "no credibility in the world as Iran's foreign minister".

The fact is that Iranian hardliners resent him for agreeing to dismantle much of the country's nuclear programme. Those around the supreme leader have gradually wrested more and more control of Iran's foreign policy from him, particularly in relation to Saudi Arabia, Iraq, Syria, Yemen and Lebanon.

Mr Zarif, most observers agree, has put up a robust defence of Iran on the world stage in spite of the fact that many of Iran's positions, actions and behaviours - with which he has had little to do - have been indefensible.

How did the president respond?
In a speech on Tuesday, Mr Rouhani made no mention of Mr Zarif's resignation, but he did praise the foreign minister for his "resistance" and "capabilities".

"If our foreign ministry is doing something, it is because it is from the people and it represents the people," he said.

Later, the president's chief-of-staff, Mahmoud Vaezi, wrote on Instagram: "In the view of Dr Rouhani, the Islamic Republic of Iran has only one foreign policy and one foreign minister."

But it was not until Wednesday morning that Mr Rouhani formally rejected Mr Zarif's resignation.

"It is the belief of myself and the Supreme Leader that you are a trusted, brave and devout individual standing on the frontline against America's multilateral pressures."

Soon afterwards, Mr Zarif was seen alongside the president at a welcoming ceremony in Tehran for visiting Armenian Prime Minister Nikol Pashinyan.

In an Instagram post, Mr Zarif said he "had no other concern but the glory of foreign policy and the credibility of the foreign ministry".