Netanyahu, who served an earlier three-year term in the 1990s, had warned on Sunday of "a left-wing government risky to the state of Israel".
A sense that he was living on borrowed time after 12 consecutive years in office was compounded by criminal charges over alleged favours to media tycoons and illegal receipt of expensive cigars and champagne.
The agreement still needs to be approved by the Knesset, or parliament, in a vote that is expected to take place early next week.
The so-called change government will be supported by Ra'am, an Islamist party that is playing the role of a tiebreaker after four elections in two years failed to deliver a clear result.
If Lapid misses Wednesday's deadline - marking the end of a 28-day presidential mandate to put together a coalition - parliament will have three weeks to agree on a new candidate.
"The coalition negotiation team sat all night and made progress toward creating a unity government", a Bennett spokesman said in a statement.
Not much unites the parties other than their desire to oust Netanyahu, and the parties differ in their stances on some of the country's most pressing issues, especially relations with the Palestinians.
The son of American immigrants, Mr. Bennett, 49, is a former software entrepreneur, army commando, chief of staff to Mr. Netanyahu and defense minister.
Once it is confirmed by the 120-member Knesset legislature, it would end the long reign of the right-wing leader who has long dominated Israeli politics. But he's more moderate when it comes to social issues such as LGBTQ rights.
The alliance would be led until 2023 by Naftali Bennett, a religiously observant former settler leader who opposes a Palestinian state and wants Israel to annex the majority of the occupied West Bank.
Since April 2019, Israel has seen four elections, with Netanyahu only able to form a government coalition once, and dissolving the Knesset, the country's parliament, another three times.
Lawmakers will now vote on the government in about 10 days.
Herzog, 60, is a former head of Israel's Labor Party and opposition leader who unsuccessfully ran against Netanyahu in the 2015 parliamentary elections.
In a statement on Twitter, Lapid said he had informed the country's president of the deal.
But after a cease-fire was reached on May 21, the negotiations resumed, and Lapid raced to sew up a deal. This step might not happen until Monday, which means the vote could be held as late as June 14. A collapse of the ceasefire with the Hamas-led militants in Gaza or another outside event could also topple the burgeoning new government.
The formation of the new government marked a rare defeat for Netanyahu: the last time he and his wife Sara had to pack their bags and move out of the prime minister's residence was before the turn of the millennium.
Mr Netanyahu, desperate to remain in office while he fights corruption charges, is expected to do everything possible in the coming days to prevent the new coalition from taking power. In an editorial, The Jerusalem Post warned that "the hard part is just beginning" for the disparate coalition but said it "has a chance to really change Israel for the better" after years of political turmoil.
Netanyahu on Sunday defiantly condemned the alliance against him as opportunistic and "the fraud of the century", warning it would result in "a left-wing government unsafe to the state of Israel".