After a day of twisting arms and striking side deals, Senate Republicans muscled through an overhaul of the tax code that puts the party on the brink of its first major legislative victory of the Trump administration.

The $1.47 trillion bill cleared the Senate shortly before 2 a.m. Eastern on a 51-49 vote, as Republicans overcame the unified opposition of Democrats who argued it was a budget-busting giveaway to big business and the GOP’s political patrons. Just one Republican, Senator Bob Corker of Tennessee, voted against the measure on the grounds that it would add too much to the deficit.

The bill’s central provisions would reduce the corporate tax rate to 20 percent from 35 percent, double the standard deduction, and enhance the child tax credit for individuals. But while it would modestly reduce personal income-tax rates, millions of middle-class families could face tax increases in later years if Congress does not act again to extend the bill’s provisions. And according to independent analyses, some people in larger, high-tax states like New York, California, New Jersey, and Illinois could see an immediate tax hike: Their cuts would be wiped out by the elimination of a provision allowing them to deduct their state-and-local income taxes off their federal bill.

Yet GOP senators made compromises everywhere—except with Democrats. In the end, self-described deficit hawks voted for legislation that, according to the nonpartisan Joint Committee on Taxation, would increase the nation’s budget gap by $1 trillion over a decade even after factoring in economic growth. Supply-siders allowed tax cuts for individuals to expire after six years while making them permanent for corporations. And Republicans who blanched at gutting Obamacare earlier this year agreed to eliminate the law’s individual mandate as part of the tax bill.

Passage of the proposal sets up negotiations with the House on a final bill for President Trump to sign that would represent the most far-reaching change to U.S. tax policy in more than 30 years, as well as the most significant one-party legislation to pass since the Affordable Care Act in 2010. Republicans hope to enact their tax package by Christmas.

Aside from Corker’s defection, Saturday’s vote was a rare display of unity from a Senate Republican conference that could not agree on a repeal of Obamacare earlier this year. And it showed how much more comfortable Republicans are with cutting taxes than with just about any other legislative issue, much less health care. Supporters of the bill said it would deliver tax relief, on average, to families at every income level while putting U.S. businesses on a more competitive footing with their global competitors.

Democrats countered it would do nothing of the sort.

“With the passage of this tax bill, today will be the first day of a new Republican party – one that raises taxes on the middle class, abandoning its principles for its political paymasters,” Senator Charles Schumer of New York, the Democratic leader, said in the lead-up to the vote.

In the end, Republicans decided to essentially ignore a late report from the congressional Joint Committee on Taxation finding that their bill would add $1 trillion to the debt over 10 years because it wouldn’t translate to the kind of economic growth party leaders had promised. The nonpartisan analysis came out on Thursday at the same time that GOP deficit hawks, led by Corker and Jeff Flake of Arizona, were learning that their proposal for a provision triggering future tax increases would not comply with Senate budget rules.

But rather than accommodate the deficit hawks by scaling back the tax cuts, party leaders won the final critical votes elsewhere. They deepened tax breaks for so-called “pass-through” businesses to win over Senators Ron Johnson of Wisconsin and Steve Daines of Montana. Bowing to Senator Susan Collins of Maine, they restored a state-and-local property-tax deduction up to $10,000. And they made Flake a completely unrelated commitment to work on a fix for undocumented immigrants who are at risk of deportation starting in March, when Trump ends former President Barack Obama’s Deferred Action for Childhood Arrivals program.

The only holdout who apparently won nothing was Corker, the retiring Tennesseean who had vowed he would not support a tax bill that added “one penny” to the deficit. Republican leaders apparently decided they didn’t need his vote, and late Friday afternoon, he confirmed they wouldn’t get it. “I am disappointed. I wanted to get to yes,” Corker said. “But at the end of the day, I am not able to cast aside my fiscal concerns and vote for legislation that I believe, based on the information I currently have, could deepen the debt for future generations.”

Just like their counterparts in the House, Republicans on the Senate Finance Committee spent months writing the chamber’s original draft. But it got passed in a madcap rush, as party leaders rewrote the bill in significant ways to win the final, crucial votes. Well into the afternoon, Republicans were literally still writing the bill. Democrats took to the Senate floor to deride the GOP’s hurry to pass the legislation that Senator Ron Wyden of Oregon said they were drafting “on the fly.” Senator Claire McCaskill of Missouri tweeted that her office received a list of changes first from lobbyists on K Street. And when the 479-page text of the revised proposal finally came out early in the evening, Democrats were appalled to find that sections of the bill were written by hand, with some provisions crossed out with lines across a page. “This makes no sense,” Senator Michael Bennet of Colorado said on the Senate floor.

One of the few significant amendments that received a vote came from Republican Senators Marco Rubio of Florida and Mike Lee of Utah, who had been pushing to expand the child tax credit even more than Republicans already plan to do. The Senate proposal would double it to $2,000 per kid, but Rubio and Lee wanted to make it fully refundable so that lower-income families who pay less in taxes can take advantage. To offset the cost, they would cut the corporate rate to 21 percent instead of 20 percent—threatening a red line that Trump and conservatives have drawn on the latter number. But the amendment failed by a wide margin, 71-29, as most Democrats declined to help Rubio and Lee make a change they might otherwise have supported as policy.

Democrats offered amendments late into the night, to no avail. They tried several times to send the bill back to committee and as a last-gasp delay tactic, Schumer offered a motion to delay the vote until Monday to give the Senate more time to scrutinize the bill. But Republicans defeated all of those efforts on party-line votes. And in perhaps the final drama of the night, not a single Democrat broke ranks and supported the final bill.  Senators Joe Manchin of West Virginia and Heidi Heitkamp of North Dakota had not ruled out working with Republicans. They are facing reelection bids in states where Trump remains popular, and while they were not expected to help pass the tax bill, there was speculation they would vote for it once Republicans demonstrated it was going to pass.

But both Manchin and Heitkamp rejected the final bill, denying the tax overhaul the bipartisan support Republicans said they wanted but never really tried to gain.