In the wee hours of Saturday, after working for hours to rewrite major sections of the bill behind closed doors, the GOP-controlled Senate voted 51 to 49 to pass a bill overhauling the American tax code, exploding the deficit and gutting a key piece of the Affordable Care Act. The Senate passage advances the bill to a conference with the House, where its differences with a version passed before Thanksgiving must be hammered out.

Senators told TPM on Friday that a combination of late night wrangling, horse-trading, and promises for future votes secured the support of enough senators to get the bill across the finish line.

Sen. Jeff Flake (R-AZ), who just a few days ago threatened to withhold his vote over concerns the bill will blow at $1 trillion hole in the federal deficit, announced Friday morning that he had been won over with a promise from the Trump administration not to pass a fix for undocumented young people stripped of legal protections, but to simply include him in future negotiations on the topic.

“They committed to move forward with me and work with me on it,” he told reporters.

Another former holdout, Sen. Susan Collins (R-ME), also based her vote on promises from the Trump administration and Senate leadership: one to pass two health care bills to mitigate the damage wrought by the repeal of Obamacare’s individual mandate, and another to waive the deep automatic cuts to Medicare that would be triggered by the tax bill’s enormous price tag.

Collins shared a letter from Senate Majority Leader Mitch McConnell (R-KY) detailing the latter promise shortly after announcing her ‘yes’ vote.

I received assurances today that no reduction in Medicare will be triggered by tax bill. See exchange of letters. pic.twitter.com/Z3mbHjr0NE — Sen. Susan Collins (@SenatorCollins) December 1, 2017

Both of McConnell’s promises to Collins, however, depend on what Democrats in the Senate and Republicans in the House of Representatives do—groups well beyond his control.

The looming automatic federal spending cuts cuts can only be waived by a majority of the House and a 60-vote supermajority of the Senate.

Democrats are not eager to go along with cuts to Medicare or other social safety net programs, but are also averse to helping to extract Republicans from the mess they made for themselves. At the same time, some Republicans may see deep cuts to social programs as a a desirable trade off for tax cuts.

As for the health care bills to protect the health insurance market from the repeal of the individual mandate, there is widespread hostility to them in the House, and experts say even if they do pass, at least 13 million more people will be uninsured as a result of the mandate’s repeal.

In the end, every former holdout came away with something to show for their previous opposition except Sen. Bob Corker (R-TN), who ironically was the deciding vote to pass the bill out of committee earlier this week, a decision he made based on promises from leadership to address his fears the deep tax cuts would balloon the federal deficit.

But after exploring the creating of a deficit “trigger” that would kick in after five years and raise some taxes if federal revenues crater as a result of the bill, and finding that such a mechanism would not fly under the Senate’s rules, Republicans opted instead to ignore Corker and include no safety net to protect the federal budget in case the promised economic growth fails to materialize.

“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 burden on future generations,” Corker wrote in announcing his ‘no’ vote Friday afternoon. “It would have been fairly easy to alter the bill in a way that would have been more fiscally sound.”

A few hours before the final vote, the Senate’s Republican Whip Sen. John Cornyn (R-TX) told TPM that leadership overrode Corker’s concerns and convinced every other member of the caucus—despite ample evidence to the contrary—that the tax cuts will pay for themselves.

“There are those of us who simply believe that the economy will grow much faster than the Joint Committee on Taxation projects,” he said. “Their modeling is defective.”

Asked if the discussion got heated, Cornyn replied sarcastically: “We all just linked arms and sang Kumbaya.”