(Peter Stevenson/The Washington Post)

President Trump has gotten a hard lesson from his first legislative debacle: Leadership takes more than being able to close a deal.

“I hope that Trump is going to learn from this that he has no choice except to be the chief legislator,” said former House speaker Newt Gingrich. “Trump has to start with the American people and come back to Congress. He can’t start with arcane congressional procedures and go to the American people. That is exactly backward.”

Nothing has more united Republicans over the past seven years than their vow to repeal and replace the Affordable Care Act.

But Trump provided little by way of specifics on how he intended to do that, beyond vague and sometimes contradictory statements.

As a candidate and as president, Trump stuck to glossy promises of a transformed medical system that would be “a lot less expensive,” provide “great health care” and “take care of everybody.”

Which Republicans forced Trump to pull the health-care bill

Outsourced to House Speaker Paul D. Ryan (R-Wis.) was the job of coming up with the legislation that would deliver on that promise. The idea was that Trump’s legendary dealmaking skills would bring it all together at the end, allowing him to take credit for victory.

Again and again, Trump’s team referred to the president as “the closer,” bringing the negotiating skills of the business world to governing. At the 11th hour, he delivered a dramatic ultimatum straight from his best-selling “Art of the Deal”: If the House did not approve the bill, he would walk away and Obamacare would stand.

“The president has been working the phones and having in-person meetings since the American Health Care Act was introduced,” White House press secretary Sean Spicer said Friday afternoon, less than three hours before the legislation was pulled from the House floor. “He’s left everything on the field when it comes to this bill.”

It was never going to be easy.

Once Republicans got beyond the promise of repealing Obamacare and into the hard trade-offs required to put something in its place, “all of the tectonic fissures in the party emerged,” said William A. Galston, a senior fellow in governance at the Brookings Institution. “They were there all along. It’s not like this bill created them.”

Trump seemed a little taken aback by the hostility within his party, and particularly the resistance of the conservatives who call themselves the Freedom Caucus.

(Alice Li,Jayne Orenstein/The Washington Post)

“There are years of problems, great hatred and distrust, and, you know, I came into the middle of it,” he said in an interview with The Washington Post’s Robert Costa.

But Trump’s engagement at the end, to sell a bill that had been written in Ryan’s office, came too late.

In retrospect, it is now apparent that more difficult and painstaking work should have been done on the front end, allowing input from various Republican factions into the bill’s design and for aggressively making the case for it to a wary public.

A Quinnipiac University poll released Thursday showed just 17 percent of Americans saying they approved of the GOP bill. The Congressional Budget Office projected that 24 million fewer Americans would be insured 10 years from now if the legislation were enacted.

Adding to the political challenge was the fact that the House bill was structured to conform to the legislative process, specifically to get around the threat of a filibuster in the Senate.

Many of the proposals most popular among rank-and-file Republicans — such as allowing insurance companies to sell policies across state lines — were to be delayed.

“We all learned a lot. We learned a lot about loyalty,” Trump said after the decision to put the bill in limbo. “We learned a lot about the vote-getting process. We learned a lot about some very arcane rules in obviously both the Senate and in the House.”

It was, in other words, business as usual.

But Trump was elected in part because he had promised not to abide by the normal way of doing things in Washington. “To have a process that said there’s going to be Part 2 and Part 3 goes against the spirit of where we are now,” Gingrich said.

Ryan blamed the result on “the growing pains of governing.”

“We were a 10-year opposition party, where being against things was easy to do. You just had to be against it,” the speaker said. “And now in three months’ time we tried to go to a governing party where we actually had to get 216 people to agree with each other on how we do things.”

The speaker insisted that the failure on health care should not be read as a prologue to what will happen with other big items on the GOP wish list.

“We have even more agreement on the need and the nature of tax reform on funding the government, on rebuilding the military, on securing the border,” Ryan said.

But history suggests that all of those are likely to demand a deep level of involvement and advocacy from the Oval Office.

The last president to achieve a major overhaul of the tax system, for instance, was Ronald Reagan in 1986. His Treasury Department began with a comprehensive, detailed proposal to back up his call for lower rates and a simplified system. But it still took nearly two years, major revisions and several near-death experiences to pull the legislation over the finish line.

Back then, however, Republicans seeking to rewrite the tax code had significant numbers of Democratic allies. In the current polarized environment, the two parties rarely work together on anything.

With 237 votes in the House, Republicans have few to spare.

“We need to get 216 people to agree with each other to write legislation, not 210, not 215,” Ryan said.

He might have added one more: a president who is leading the way, rather than coming in at the close.