Still, legislative leaders had initially been resistant to the idea of any income tax increase in a state where residents already face some of the most onerous tax burdens in the country.

After the deal was announced, Mr. Murphy said the final tax was now a “multimillionaire’s tax.”

But the prospect of a second shutdown in two years, which would have been an unwelcome stain on Mr. Murphy’s first year in office, proved motivation enough for both sides to broker a last-minute deal, despite weeks of bitter negotiations characterized by personal attacks.

“It was a hell of a journey, Governor,” Mr. Sweeney said during the news conference. “This is my ninth budget; it was probably just as hard as the other ones. But you know something, changing course, changing course in New Jersey is never easy.”

Mr. Murphy and legislative leaders were adamant that their differences were not as severe as it appeared during the monthslong standoff.

“We had honest, blunt, sometimes heated yet always civil discussions,” Mr. Murphy said, adding, “There was never a disagreement about our values and our principles. Just as how best to get there.”

The Senate and the Assembly were scheduled to vote on the budget on Sunday morning and Mr. Murphy pledged to sign it “as soon as humanly possible.”

The mere threat of a shutdown infuriated many residents of the state, who were decamping to state parks and beaches for extended holiday vacations. When the state shut down in 2017, Island Beach State Park and the rest of the state park system closed, forcing campers to pack up early and leaving a 10-mile stretch of beach vacant, except for the now infamous gathering of former Gov. Chris Christie, a Republican, and his family.