It took far longer than anyone imagined on Sunday, but New Jersey finally has a state budget.

The state Legislature put the finishing touches on a $37.4 billion state budget deal in the early evening -- 24 hours after Gov. Phil Murphy and top lawmakers announced they had spared New Jersey a no-holds-barred political brawl and its second-straight state government shutdown.

Murphy then signed the spending blueprint several hours later, announcing it a few minutes before midnight Sunday.

Lawmakers had planned to vote at 8 a.m. Sunday on the budget agreement and related bills. But that was held up until the early evening as Murphy and his fellow Democrats who control the Legislature scrambled to nail down legislative language to close a corporate tax loophole.

Lawmakers would have preferred more time for the bill to come together, but state Senate President Stephen Sweeney said Murphy "insisted" they convene at 8 a.m. -- fewer than 13 hours after striking a deal -- to pass the budget bills.

"We came, we waited and we got it done," Sweeney said early Sunday evening.

The state Assembly passed the final budget bills at about 6:40, and the Senate quickly followed suit.

Murphy, a Democrat, and the legislative leaders of his party were in disarray in recent weeks as they sought agreement on which taxes to raise to underwrite increased spending on education, transit, government worker pensions and other items on Murphy's progressive wish list.

A deal came together late Saturday evening, just hours before the constitutional deadline for the governor to sign a budget into law for the fiscal year that just began.

It won't raise the sales tax, as Murphy had wanted, but will set hit really wealthy taxpayers with higher taxes on income above $5 million. That's expected to raise about $280 million in new revenue.

It also includes higher corporate taxes and closes loopholes that are expected to generate more than $800 million.

While Democrats sped to get the bill passed in the Sunday evening, Republicans decried the budget as a blueprint to scare away businesses and jobs.

Assembly Minority Leader Jon Bramnick, R-Union, said that July 1, 2018, "should be declared Phil Murphy tax and spend day" in New jersey.

The budget bill passed Saturday will raise the state income tax deduction for property taxes to $15,000 creates a new child care and dependent tax credit and takes a small step toward tuition-free community college.

It will also pump an extra $402 million into public schools.

The budget does not include his plan to raise the sales tax from 6.625 percent to 7 percent, but will expand the tax to include such online rentals as Airbnb.

The state will also collect a 50-cent surcharge on rides through such ridesharing apps as Uber and Lyft and a 25-cent surcharge on shared rides.

The budget also anticipates collecting $200 million from a tax amnesty program that allows delinquent taxpayers to settle up at a discount.

Corporations with net income over $1 million will pay 11.5 percent this fiscal year and next, representing a 2.5 percent surtax. That will be cut to 1.5 percent in years three and four before phasing out entirely.

Sweeney fixed his sights on businesses after federal tax reform cut the corporate tax rate from 35 percent to 21 percent beginning this year.

Money fell from the sky, the Senate president said previously.

"They're not happy about (the state tax increase), but it's hard for them to argue the fact that they got this windfall: $2.9 billion in New Jersey alone, for doing nothing," he has said.

When Murphy announced on Twitter he signed the bill, he also took a jab at his Republican predecessor, Chris Christie -- who made international headlines during last year's shutdown when photos emerged of him lounging on a closed state beach.

A year ago, government shut down and beaches were closed (for most of us, anyway...)



A year later, we passed a budget with huge investments in public schools, property tax relief, and @NJTRANSIT and gave the middle class a break by ensuring the wealthy pay their fair share. — Governor Phil Murphy (@GovMurphy) July 2, 2018

NJ Advance Media staff writer Brent Johnson contributed to this report.

Samantha Marcus may be reached at smarcus@njadvancemedia.com. Follow her on Twitter @samanthamarcus. Find NJ.com Politics on Facebook.