“Get your ass in line,” Speaker John Boehner had told House Republicans who resisted his plan to raise the debt ceiling and avoid a default.

But really, it was Boehner’s butt that was on the line — and late Thursday night, he had it handed to him.

For his six-month-old speakership, it was a grievous if not mortal wound. The legislation under consideration was fairly pointless — a solution to a self-inflicted crisis that faced certain defeat in the Senate — but Boehner made it into a test of his leadership. And rank-and-file Republicans returned a vote of no confidence.

After a day of cocky predictions, GOP leaders suddenly pulled the bill from the floor Thursday evening — and when five hours of backroom arm-twisting failed to change enough minds, they called off the night’s vote. Leadership on Friday rewrote the Boehner Plan to suit the conservative palate, but that only affirmed that the Tea Party was leading the speaker and not vice versa.

Whether Boehner’s team can survive such a public failure will be of interest to political gossips. But the thwarting of the Boehner Plan also displayed how ungovernable the House Republican majority is. With the nation just days from a default, the chamber is at the mercy of a handful of people who believe they are on a mission from God.

“Where’s the chapel?” Rep. Tim Scott (S.C.) asked as he emerged from an arm-twisting session with Majority Leader Eric Cantor Thursday night. The freshman lawmaker explained that he wanted to “go to the divine source.”

In a room off the Capitol Rotunda, Scott joined a prayer session with fellow South Carolinian lawmakers. “I hope the Lord . . . gives men wisdom when they desperately need it,” Scott explained.

As it happens, the Lord gave Scott the wisdom to oppose Boehner. “I think divine inspiration already happened,” Scott said. “I was a ‘lean no’ and now I’m a ‘no.’ ” And he’s not much worried about default, saying: “I hope the Lord blesses our nation in a way that is measurable.”

The Lord will surely bless the nation with higher interest rates, if not outright economic collapse, in a default. But Thursday night’s debacle proved that there are enough House Republicans who would prefer that to raising the debt limit — even if they bring down their speaker in the process.

“I’m still no. . . . I can’t vote for it the way it is,” Rep. Jason Chaffetz (Utah) announced after a session with Republican leaders just before 10 p.m.

“The speaker has said he can’t do his job if you guys aren’t there to support him,” ABC News’s Jon Karl pointed out. “This is his most important vote yet as speaker.”

“I just can’t support his bill, but I do support the speaker,” Chaffetz concluded.

To be on Capitol Hill on Thursday was to watch a speakership crumble in real time. Compounding Boehner’s problem was that he had foresworn the earmarks used to buy off recalcitrant backbenchers. And these Tea Party freshmen were elected to vote against pretty much everything.

In bringing the Boehner Plan to the floor, the speaker abandoned the reforms he promised when he took over the House. In the minority, he complained that Democrats rushed bills without sufficient notice and wasted time on trivial items. “With all the challenges facing our nation, it is absurd that Congress spends so much time on naming post offices,” he complained in September 2010.

But Republicans rushed this bill to the floor without the promised notice, and, after hours of debate, the presiding officer announced just before the scheduled vote that the House would instead take up: post-office namings. They went from Peoria, Ill., to Guam before recessing.

Off the floor, GOP leaders engaged in five hours of the sort of backroom dealings they deplored under Democratic rule. No fewer than 40 pizzas were delivered to the offices of Boehner, Cantor and Whip Kevin McCarthy, as various delegations — South Carolina, Arizona, Georgia — arrived for private coercion sessions.

A throng of about 100 reporters clogged the hallway and quarreled with police outside Boehner’s offices. But two hours later, there was no progress. “We’ve got some work to do,” Rep. Mike Conaway (Tex.), a member of the whip team, reported at 8 p.m.

Evidently. A few tipsy GOP lawmakers, returning from dinner, pretended to give tours of the statues in the Capitol. They, and the leadership, continued to insist a vote was imminent. But just before 10:30 p.m., McCarthy emerged from the speaker’s office to call it off for the night.

Lawmakers got to work on the Sisyphean task of retooling the Boehner Plan into a more conservative proposal that was also certain to be rejected by the Senate. Regardless, damage had been done — both to Boehner’s speakership and to the House, now under the control of people who think God demands default.