In his statement, Hariri said Iran was "losing in its interference in the affairs of the Arab world", adding that Lebanon would "rise as it had done in the past" and "cut off the hands that wickedly extend into it".
In November that year, he became prime minister, forming a unity government with Hezbollah and its allies after marathon negotiations.
Hariri has visited Saudi Arabia, a political foe of Iran and Hezbollah, twice in the past week, meeting Crown Prince Mohammed bin Salman and other senior officials.
Rafik al-Hariri was killed by a bomb in 2005 in an attack widely blamed on Hezbollah.
Hariri has Saudi citizenship and has tirelessly praised the kingdom, from which he announced his resignation. "It indicates the Saudi decision to confront Iran and the Iranian influence in Lebanon by going after Hezbollah".
Hazem al-Amin, a Lebanese writer who follows regional affairs, said Hariri's resignation is "completely a Saudi step" that comes in the context of an worldwide and regional atmosphere against Hezbollah and against Iranian influence in the region.
The surprise move risks plunging the small and already fragile Middle Eastern country deeper into turmoil.
They said they were now waiting for Mr Hariri to return to Lebanon to clarify the circumstances of his resignation and proceed accordingly.
Ghasemi dismissed Hariri's "baseless accusations", which he said indicate that "a new scenario" for the region was being drawn.
Taking up the prime minister's office last year, Mr Hariri promised a "new era for Lebanon" after two years of political deadlock. "The global community needs to come together and stand against this aggression", he said.
The resignation of his prime ministerial position was announced on Saturday from Riyadh, where he was on a trip.
In his speech, Saad Hariri said the atmosphere in the country is similar to the one that existed before his father, the late prime minister Rafik Hariri, was assassinated in 2005.
"By going after Hezbollah, by denying Hezbollah a credible Sunni partner in governance, it thus weakens Hezbollah on the home front", Slim said.
Hariri was also locked in a standoff with Hezbollah over funding for the Special Tribunal for Lebanon, which is prosecuting his father's murder and had implicated Hezbollah members. His attacks on Hezbollah come on the heels of new US sanctions on the group that many fear will impact negatively on the Lebanese economy. The group's intervention in Syria is highly controversial in Lebanon.
"I declare my resignation from the premiership of the Lebanese government, with the certainty that the will of the Lebanese is strong", Hariri said.
In Beirut's Tarik al-Jadideh neighborhood, a predominantly Sunni neighborhood supportive of Hariri, residents described the shock resignation as a good step.
His election was made possible after Hariri endorsed him for president, based on an understanding that Aoun would then appoint him as prime minister.
Hariri meanwhile backs opposition to Assad and enjoys the support of Tehran's regional rival Saudi Arabia.
Hariri's resignation comes only a day after he met Ali Akbar Velayati, an advisor to Iranian Supreme Leader Ayatollah Ali Khamenei, in Beirut.