Iranian President Hassan Rouhani, right, listens to his Foreign Minister Mohammad Javad Zarif prior to a meeting in Tehran. File picture: Vahid Salemi/AP

Tehran - The office of Iranian President Hassan Rouhani early Tuesday confirmed the resignation of Foreign Minister Mohammad Javad Zarif but said that the president would not accept it.

Zarif had carried out his work courageously and would continue to do so, the president's office said on its Instagram page.

"Zarif will not be alone and we [the government] will all support him," the post added.

Zarif unexpectedly announced that he would be stepping down from the post via an Instagram post late Monday.

Local observers expressed surprise at the timing of the announcement, shortly before midnight, and predicted that Rouhani would reject it.

The reasons for his resignation were hotly disputed on social media, with some claiming he had had enough of constant criticism from hardliners of the 2015 nuclear deal he negotiated and the government's policy of rapprochement with the West.

Others said that he had been angered by his exclusion from a meeting with Syrian President Bashar al-Assad on Monday.

All agreed that his resignation would mean a swift end to the nuclear deal, which lifted sanctions in return for Tehran reducing its nuclear weapons capabilities and which was already dealt a blow when the US pulled out last year.

Its withdrawal and reimposition of sanctions triggered further criticism of Zarif within Iran.

US Secretary of State Mike Pompeo said the US had taken note of Zarif's resignation.

"We'll see if it sticks," Pompeo wrote on Twitter. "Either way, he and Hassan Rouhani are just front men for a corrupt religious mafia. We know [Ayatollah Ali Khamanei] makes all final decisions. Our policy is unchanged - the regime must behave like a normal country and respect its people."

Observers in Tehran believe Rouhani would not be able to replace Zarif with someone of the same standing and experience.

Neither his deputy Abbas Araghchi or Ali-Akbar Salehi, head of Iran's nuclear agency, have the same charisma as the foreign minister, whose eloquence and fluent English had been a relief to Western negotiators.