WASHINGTON ― When Donald Trump was elected president last year, a sweeping rewrite of the tax code was one of his top priorities.

Throughout the campaign, Trump said he wanted a “middle-class tax cut,” one that wouldn’t benefit wealthy people like him and would spur huge levels of economic growth while not adding to the national debt. “For the hedge fund guys, they’re going to be paying up,” Trump promised in September 2015.

As president, Trump has continued to insist the tax code overhaul won’t be good for himself or other millionaires. “This is going to cost me a fortune, this thing ― believe me,” Trump said this week.

But the big winners in the GOP bill that the Senate passed early Saturday morning are corporations and the wealthy. Trump himself ― a self-proclaimed billionaire ― stands to gain millions through the elimination of certain taxes (though we don’t know exactly how much because Trump won’t release his tax returns). Far from being a middle-class tax cut, the measure is a massive corporate giveaway, a bill that recycles decades of Republican ideology on trickle-down economics and trusts that executives will hand over their new gains to average-income workers.

“If my friends here want to give a tax cut to the middle class,” Sen. Sherrod Brown (D-Ohio) asked on the Senate floor Thursday, “why don’t we give a tax cut to the middle class?” His argument had no effect.

After months of negotiations, the Senate passed the proposal, 51-49, with just one Republican ― Bob Corker of Tennessee ― joining all Democrats in opposition. Corker took issue with how much debt the bill would produce, and after the Senate parliamentarian struck down Corker’s debt-control proposal, GOP leaders invited the retiring Republican to just vote no rather than finding him an accommodation.

With the bill finally through the Senate ― the House passed its tax bill two weeks earlier ― the two chambers still have to work out their legislative differences in a conference committee before the tax rewrite becomes law. There’s a slim chance the House could adopt the Senate bill and send it to the president’s desk, but it’s more likely that negotiators will merge the two versions. Both chambers need to pass the same measure for the bill to become law.

For most Americans, the legislation is still indeed ― at least in the short term ― a tax cut. Those cuts are due in large part to Republicans approving $1.5 trillion in added debt over the next 10 years. But of that pie, the wealthy disproportionately benefit, and some households could wind up with higher tax bills. The richest 20 percent of households reap 90 percent of the benefit of the tax cuts over that time period, according to the nonpartisan Tax Policy Center.

Still, in the short term, it’s difficult to say exactly whose taxes go up and whose go down. Tax burdens depend on what deductions individual filers claim, and this bill is a complicated tax code rewrite ― one that analysts say will have limited impact on the economy, will cost the nation more than a trillion dollars over the next 10 years, and will do much more for rich investors than it will the middle class.

Despite all that, despite poll after poll showing the measure is unpopular, most Republicans were ecstatic to pass the bill.

While the bill took months to draft, the final package came together over a frenetic last few days. Republicans didn’t even have finished legislative text until Friday night, hours before the vote, and Democrats slammed their GOP colleagues for rushing through a bill that was cobbled together with handwritten changes and crossed-out pages at the last minute.

Those procedural concerns did nothing to slow the bill, however, with Republicans falling in line to vote down a Democratic motion to adjourn Friday night. Senators then began a so-called vote-a-rama, in which amendments get up-or-down approval one after the other until lawmakers are exhausted enough to stop. Eventually, in the early hours of Saturday morning, senators moved to a final vote on the reconciliation bill, and it passed.

To get the bill over the 50-vote threshold for reconciliation legislation, GOP leaders cut deals this week on how much certain businesses could deduct off the top of their tax bills, as well as on what would be included in an upcoming government funding measure.

Sen. Susan Collins (R-Maine), for example, demanded that year-end spending legislation include funding for Obamacare subsidies that the Trump administration has targeted. Sen. Jeff Flake (R-Ariz.) said he got assurances on a contentious immigration program, Deferred Action for Childhood Arrivals, though Trump administration officials said Flake only got assurances on being part of the conversation.

Overall, the legislation would cut the corporate tax rate from 35 to 20 percent, which has been the GOP’s priority all along. Republicans say this dramatic reduction will unleash the economy and raise wages by making big businesses more internationally competitive ― claims that are dubious according to corporate executives themselves, who say they will throw the money at shareholders instead of workers.

In addition to reducing corporate and individual tax rates across the board, the bill would simplify the tax code by getting rid of most deductions, which businesses and individuals use to reduce the amount of their income subject to taxation.

Because Congress over the years has added write-offs in order to encourage and subsidize certain endeavors ― such as homeownership and higher education ― the mass elimination of these tax preferences could have wide-ranging effects that are incidental to the overall Republican goal of encouraging business investment.

Axing deductions for state and local taxes, for instance, while increasing the value of a fixed “standard deduction,” would result in far fewer households finding it worthwhile to deduct the amount they spend on mortgage interest. A study commissioned by the National Association of Realtors earlier this year said the proposal would reduce home values by 10 percent (which could be a good thing for people who don’t already own homes). Republicans have long championed homeownership but have been undeterred by a lobbying blitz from the real estate industry.

While fewer deductions makes for a simpler tax code, the bill would also create a complicated new deduction for certain businesses that aren’t taxed as corporations. Determining which firms have the kind of “qualified business income” eligible for the deduction will require many pages of new IRS regulation, though the bill explicitly excludes high-income service providers like accountants, lawyers and investment managers.

In the day before the final vote, Republicans increased the value of the deduction to win over Sens. Ron Johnson (R-Wis.) and Steve Daines (R-Mont.), both of whom had previously withheld support because they felt the legislation disproportionately benefited firms that pay the corporate tax.

And in a catchall “manager’s amendment” adopted just before the bill passed, Majority Whip John Cornyn (R-Texas) added a provision to allow publicly traded partnerships to claim the new deduction. Victor Fleischer, a tax professor at the University of San Diego School of law, said that the Cornyn amendment would specifically benefit oil and gas companies.

“We should all re-read ‘Why Nations Fail’ after this tax bill passes,” Fleischer said on Twitter.

Another provision in the manager’s amendment, inserted by Sen. Pat Toomey (R-Pa.), would have exempted schools that don’t take federal funds, such as the conservative Hillsdale College in Michigan, from a new tax on college and university endowments. The tax seems designed less to raise money than to poke educated liberals in the eye. Several Republicans joined Democrats in defeating the amendment. Toomey’s office did not respond to a request for comment.

To keep the cost of the bill beneath $1.5 trillion ― an arbitrary level Republicans set for themselves in a budget process earlier this year ― almost all of the tax cuts for individuals expire at the end of 2025. Republicans say that expiration won’t happen, noting that even President Barack Obama made nearly all of the Bush tax cuts permanent when they were up for reauthorization.

But for all the GOP bluster about this bill being a tax cut for the middle class, and for all the rhetoric about the false necessity of making tax cuts permanent, the bill would keep the corporate tax rates the same while putting the individual rates up for expiration. Because of those temporary cuts, the Joint Committee on Taxation, which scores tax legislation for Congress, found that most households earning less than $75,000 annually would pay higher taxes 10 years from now.

Just before debate began Friday night, Sen. Bernie Sanders (I-Vt.) said on the Senate floor that this day would be remembered as one of the “great robberies in U.S. history.”

CORRECTION: An earlier version of this story incorrectly reported that Toomey’s Hillsdale carveout had been adopted. This story has also been updated to clarify which industry Fleischer says would benefit from Cornyn’s amendment.