Rep. Mark Meadows (R-NC) walked out of a meeting Thursday afternoon with an ultimatum over his head and his health vote uncertain. President Trump had just ordered a vote on his endorsed plan to repeal and replace Obamacare, a bold attempt to break Republican rebels and ram the plan through the House. Meadows led one of the rebel groups, the House Freedom Caucus, and Trump had forced him into a choice: back a bill that Meadows said left too much of Obamacare in place, or shun it and allow the whole law to stand.

This is The Art of the Deal in action, one reporter said, as Meadows emerged from the gathering of House Republicans. “Yeah, I read his book too,” Meadows replied, smiling. “In order to get the best deal, you always have to be prepared to walk away.”

Trump had walked away. “The president wants a vote tomorrow one way or another,” Rep. Chris Collins (R-NY) said, walking out of the same meeting. “If it doesn’t pass, we’re moving beyond health care.”

The next 18 hours would be a test of Trump’s move — whether it would succeed and Trump would be hailed as a master negotiator, or whether conservatives like Meadows, and moderates with their own concerns, would call his bluff and defy him on the floor.

It would end with Trump folding.

For a moment, Trump looked like he was in control

Late Thursday, it appeared as though Trump had, after days of negotiations and grim-looking whip counts, found a path to victory in the House.

That day, he invited both the conservative Freedom Caucus and the Tuesday Group — the moderate Republicans in the conference worried the bill was moving too far to the right — to the White House. Everyone thought they had the ear of the president, and the power to demand more from him in the bargain.

“Anytime you don't have 216 votes, negotiations are not totally over," Meadows had said after the White House meeting. “Whether the vote is tonight, tomorrow, or five days from here ... we're going to get to the finish line.”

Trump, though, had decided he was done negotiating.

That news came down to House Republicans in their conference meeting Thursday afternoon. Party leadership tried to marry the pressure of an impending Friday vote with a rallying cry for party unity. It was working. Strongly conservative members of the House stood up and publicly changed their votes to yes — even some in the Freedom Caucus, Meadows confirmed.

Not everyone was swayed. After the meeting, Freedom Caucus members Dave Brat (R-VA) and Raúl Labrador (R-ID) piled into an elevator to meet with members of their caucus. But they would have “nothing to report,” Brat said.

Their chair, Meadows, was still a no vote, but a more sheepish one. He admitted there was a “motivating” argument against opposing the bill: It would leave Obamacare as is.

Faced with a list of amendments Trump and House leaders had made to the bill — all of them making it more conservative — Meadows paused. “That’s true the deal has improved,” he conceded. “I’ve got to run the numbers tonight,” as if to imply there was room in his stance.

The momentum shifted again on vote day

On Friday morning, the halls of the Capitol were quiet. On the House floor, debate on the bill had begun. Democrats denounced it with rousing speeches and giant poster boards.

The Republican side of the room was almost empty. The House was in the motions of moving toward a vote, but with every hour, social media brought more news of GOP defections. The fervor of Thursday night had given way to Friday morning sobriety, of unpopular provisions and constituent pressure.

Trump’s negotiating had moved to Twitter, trying to whip conservative votes. “The irony is that the Freedom Caucus, which is very pro-life and against Planned Parenthood, allows P.P. to continue if they stop this plan!” he tweeted.

By 10 am, Mo Brooks, a Freedom Caucus member, came out a firm no: "I will vote against the American Health Care Act because it has more bad policy than any bill I have ever faced," he said.

Then Rep. Rodney Frelinghuysen (R-NJ), the chair of the Appropriations Committee, came out as a no, concerned about the loss of coverage in his “Medicaid-dependent state.” By 1 pm, Rep. Barbara Comstock (R-VA), an ally of House Speaker Paul Ryan’s who had been notably silent on the bill, followed suit.

Part of the “Coverage Caucus,” members concerned that the American Health Care Act would take away health insurance from too many people, Comstock is among the handful of Republicans representing a district that voted for Hillary Clinton in November. The final concessions made to the Freedom Caucus, repealing essential health benefits like maternity care and mental health, had lost her vote.

Trump’s attempt at a balancing act was faltering.

“I think if it passes, it passes by two,” Collins said in the early afternoon, talking about his own whip count. “I have 21 hard no’s and another 20 on the bubble. Let's put it this way: They want to vote no. If it goes down, it goes down by 40.”

Nothing could be changed that wouldn’t lose votes on either side of the caucus, and Trump’s ultimatum was souring the conference.

Paul Ryan went to the White House, the end

The clock was running out.

Just a few hours before the 3:30 vote on Friday, Ryan paid Trump a visit, reportedly to tell him their efforts had come short — they didn’t have the votes. Under Trump’s previous instruction, this would mean the bill would die on the floor.

But at 3:35, House Republicans weren’t casting their votes — they were called in to the same room they had been Thursday night. The meeting was short. As the last representatives were pushing through the crowds of reporters to enter the room, Ryan was already leaving the conference from the back door.

“This bill is dead,” Rep. Greg Walden (R-OR) told reporters.

“We appear incapable of passing a bill that all of the conference has run on for multiple election cycles,” Rep. Matt Gaetz (R-FL) said. “I don’t know if we could pass a Mother’s Day resolution right now.”

Trump instructed Ryan to pull the bill, a leadership aide confirmed.

He had folded.

“This is the toughest, thorniest political policy issue that we currently have. My guess is that [Trump] has learned through this process that politics is different than business,” Rep. Bill Huizenga (R-MI) said, on his way to treat his staffers to consolation drinks.

After 17 days, two overnight committee markup sessions, and three manager’s amendments, Obamacare remained the “law of the land,” Ryan said in a press conference.

“It felt like no matter what you did to accommodate people, they came back with a new set of things,” Walden said. “We went a long way.”

Mark Meadows had no comment.