A warming of ties between the two sides' main backers Syria and Saudi Arabia in recent weeks helped ease the rift in Beirut and led eventually to the breakthrough.
A government acceptable to all main parties is seen as key to maintaining stability in a country facing sectarian and political tensions, as well as a huge debt burden.
"The government is as good as formed," Okab Sakr, a parliamentary member, who is close to Hariri, told Lebanon's New TV station.
"It's all about the final touches now and its formation will be completed this weekend."
Leaders of the opposition, including Hezbollah chief Hassan Nasrallah, agreed to join the proposed government during a meeting on Friday night.
"Participants at the talks have agreed to forge ahead with the formation of the national unity government in accordance with the regulations that were agreed upon during the negotiations that had been conducted," Hezbollah said in a statement after the meeting.
Political sources said the opposition would officially inform Hariri of its decision and hand him over the names of their proposed ministers.
The rival factions had agreed in July on the broad division of seats in the new cabinet.
But Hariri, son of assassinated former Lebanese Prime Minister Rafiq al-Hariri, had struggled to reach agreement with opposition politicians on the details.
At the heart of the dispute were the demands of Christian leader Michel Aoun, an ally of Hezbollah. Aoun's Free Patriotic Movement holds more seats in parliament than any other Christian party.
The new 30-minister cabinet is set to include 15 ministers from Hariri's coalition, 10 from the opposition including two Hezbollah ministers, and five, including the key interior and defence portfolios, will be nominated by Michel Suleiman, the president.