House Speaker Paul D. Ryan (R-Wis.) leaves the House chamber. (J. Scott Applewhite/AP)

House Republicans are ending their eight-year run in the majority exactly the way it began — grabbing a hostage and seeking ransom.

This week’s standoff, like so many others this decade, pits an alienated House GOP caucus against its more reality-driven brethren in the Senate. The House Republicans are, again, refusing to accept their fate and continuing to insist that Washington give in to their demands even as they have struggled to muster an actual majority from their own ranks.

This time around, it’s about their demands for $5 billion in funding to build a wall along the Mexican border, a controversial idea that most experts dismiss as too expensive and not likely to succeed in stymieing border crossings — and that President Trump, when he was a candidate, repeatedly promised that Mexico would finance.

Most Republicans woke up Thursday thinking that, as their final act in the majority, they would admit they lacked the votes to approve the wall funding, then give in to the unanimously supported Senate plan to just extend current funding levels for 25 percent of the federal government until February.

However, unlike their first six years of legislating by crisis, the most conservative House Republicans have a key ally: Trump.

After a late Wednesday and early Thursday of bad TV, with conservatives accusing Trump of giving up on the wall, the president ordered House Speaker Paul D. Ryan (R-Wis.) back to the Capitol to take one last hostage before the GOP turns over power to Democrats in two weeks.

“What we’re going to do is to go back to the House and work with our members,” a dejected Ryan told reporters outside the White House after meeting with Trump.

They drafted legislation that would fund agencies for 25 percent of the federal workforce into February, along with $5.7 billion for the border wall and $7.8 billion for disaster relief. During the past two weeks, Republicans have privately doubted they had enough votes for this plan, with many departing GOP lawmakers unwilling to cast a final vote as a favor to Trump because the proposal is destined to fail in the Senate.

But late Thursday, the GOP eked out the vote, 217 to 185, and sent it back to the Senate.

With a midnight Friday deadline, House Republicans went back to a drawing board that was fraught with political risk. Worst of all, with Republicans in full control of Washington, they were essentially holding themselves hostage.

“They’re really horrible hostage-takers,” Sen. Lisa Murkowski (R-Alaska) said while she was walking to a midday luncheon that was sparsely attended as most GOP senators believed they had already finished their business Wednesday night.

This is exactly how the House GOP came to power in January 2011, bolstered by a fiery conservative freshman class with more than 80 members who rode into office on tea party energy.

But Reps. John A. Boehner (R-Ohio) and Eric I. Cantor (R-Va.), then the House speaker and majority leader, respectively, realized that, with Democrats in charge of the Senate and President Barack Obama in the White House, they could only achieve modest gains in the years ahead.

At their issues retreat, at a Baltimore hotel, the GOP leaders made a decision that would stick with these Republicans for the rest of their time in office, teaching a lesson that Republicans would never unlearn — not even in their last days in power.

In their first order of business, Boehner and Cantor began looking for hostages. First they would get a warm-up fight on the leftover government-funding bills in early 2011, and then in the summer, the big showdown, Republicans would refuse to increase the limit on federal borrowing and risk the first default on the national debt.

The GOP leaders knew that such a harrowing event could trigger a global financial meltdown, but they believed that if they could convince Obama that they were willing to blow everything up, Democrats would blink.

“Either we stick together and demonstrate that we’re a team that will fight for and stand by our principles, or we will lose that leverage,” Cantor told Republicans at the Baltimore retreat, according to an account he gave The Washington Post at the time.

Many Republicans began questioning whether a default would even hurt the global economy. One evening, the South Carolina delegation retreated from the speaker’s office to the House chapel — after prayer, they opposed Boehner’s efforts to broker a compromise.

Finally, Senate leaders took charge and crafted a convoluted plan to avoid financial disaster and impose about $1 trillion in fiscal cuts to federal budgets over a decade.

Sen. Mitch McConnell (R-Ky.), then the minority leader, came away a little alarmed by how many House Republicans were willing to breach the debt ceiling, but he was pleased with his negotiating skills. “What we did learn is this — it’s a hostage that’s worth ransoming,” he told The Post in August 2011.

By late 2012, as tax cuts and mandatory spending cuts were set to take place, House Republicans seized that debate and demanded massive spending cuts from Obama. By New Year’s Eve, Senate leaders again came in to avert a fiscal cliff.

This scenario played out more stupendously in fall 2013, when Republican demands to repeal the Affordable Care Act led to a 16-day partial shutdown of the federal government, and late 2014, when they refused to fund the Department of Homeland Security over border-crossing issues.

“It’s just silly,” retiring Sen. Bob Corker (R-Tenn.) said Thursday, reflecting on eight years of taking hostages. What was the benefit? “Nothing,” he said.

In the 2013 and 2014 showdowns, the House GOP got no concessions for their showdowns with Obama. But some Republicans believed their earliest hostage-taking moments did yield tax-and-spend plans that helped restrain surging deficits.

“But we did get it down to something like $450 billion, now it’s rising again, for a variety of reasons. But I hope historians will recognize that at least deficits were lower once Republicans took control of the House,” said Rep. Leonard Lance (R-N.J.), who was defeated in November.

A year ago, fully in control of Washington, Trump and Republicans passed a $1.5 trillion tax cut on a party-line vote and, a few months later, reached a bipartisan deal to blow up those spending caps that Lance applauded.

The budget deficit will soon top $1 trillion a year.

Lance opposed that tax plan in part because of the deficit impact. The only saving grace of taking all those hostages — the drop in the deficit in the early years of the GOP majority — has evaporated.

“I definitely believe we should fund the government,” Lance said later, after voting for the legislation and setting off another showdown with the Senate. “I don’t like brinkmanship in any way.”

Read more from Paul Kane’s archive, follow him on Twitter or subscribe to his updates on Facebook.