The Syria- and Iran-backed Hezbollah and its allies rejected a draft government proposed by Hariri this week.
Hariri, a Saudi- and US-backed billionaire, said he had held "rounds and rounds of consultations which always ended in obstruction".
"I announce to all Lebanese that I told President Suleiman today that I will step down from forming a government, in the hope that this decision will be for the benefit of Lebanon," Hariri said after a meeting with President Michel Suleiman.
Suleiman is expected to call for a new round of consultations with lawmakers to nominate a new prime minister. It is widely expected that Hariri will be selected once again by members of his majority coalition.
Hariri's move takes Lebanon into more political uncertainty.
Hariri's step-down comes two days after Hezbollah and its allies rejected his proposed team for the 30-member Cabinet.
Hariri, who has unsuccessfully tried to form a government since the June parliament elections, named his own picks for the Cabinet posts.
Hezbollah and its allies demand they name their own members in the unity Cabinet, which is to be made up of rival Lebanese factions.
AP contributed to this report