Kevin McCarthy did two things right, but too many other things wrong.

His extraordinary ouster that unsettled Washington on Tuesday and left the House in chaos was the culmination of a tumultuous nine months that began in unprecedented fashion in January with 15 roll call votes to claim his gavel and ended in unprecedented fashion with a single one to vacate the speaker’s chair.

In between, the gregarious Californian, previously known more as a backslapper and prolific fund-raiser than a legislative wizard, narrowly pulled the country back from the brink of crisis — twice. But he took many other actions, and said many things, that antagonized hard-line Republicans, Democrats and the White House. When the critical moment came, no one was willing to race to his rescue.

And he failed to master the art of corralling a deeply divided Republican majority that could never quite bring itself to rally behind him when it came time to choose normalcy over chaos. With the G.O.P. base increasingly hungry for insurgency and confrontation, Mr. McCarthy found himself out of step, a problem that is likely to plague any candidate who tries to succeed him.

“They don’t get to say they’re conservative because they’re angry and they’re chaotic,” Mr. McCarthy said on Tuesday night of the eight Republicans who voted to oust him. He added, “They are not conservatives and they do not have the right to have the title.”

Still, Mr. McCarthy practiced almost abject obeisance to the far right — right up to the moment they decided to take him down. He gave them concession after concession to win their votes to become speaker, then went back on some of the ones they cared about most, on spending, when they proved impossible to accomplish in a divided government.

Along the way, he also deeply alienated Democrats, even though he was forced to turn to them at key moments, both to avoid a calamitous federal default in May and a government shutdown last weekend.

Mr. McCarthy had promised Democrats fair treatment and a role in governing, but then pushed intensely partisan legislation that they found detestable. He cavalierly launched an impeachment inquiry into the Democratic president when he found himself on shaky ground with his right-wing troops. He cut a spending deal with the White House, then reneged on it — all the while saying he was doing what he thought was right for the nation.

Mr. McCarthy, always facile, pretty much talked himself out of his job. His trust deficit was deep all around.

“This is someone who betrays his word on pretty much a daily basis,” said Representative Adam Schiff, Democrat of California and a favorite target of Mr. McCarthy.

Some Democrats seemed legitimately torn over what to do about the push to remove Mr. McCarthy, worried about who would come after him and the likely damage to the institution if speakers can now be discarded so easily. And they certainly weren’t happy about aligning themselves with Representative Matt Gaetz, the Florida Republican who led the effort to depose the speaker and a man most Democrats — and many Republicans — can’t stomach.

But as they gathered in the Capitol Visitor Center to decide whether to overlook Mr. McCarthy’s political sins and back him, they instead ended up reciting a litany of his offenses, an indictment that could have been nailed to the House chamber door. Without Democrat support and with eight hard-core right-wing Republicans willing to vote against him, Mr. McCarthy stood no chance given the slim Republican majority that has haunted his tenure.

For Mr. McCarthy, who practiced a management style of doing and saying pretty much whatever it would take to get through the day, tomorrow finally arrived.

“This is a somber day for America as the chickens come home to roost for Kevin McCarthy,” said Representative Jamie Raskin, Democrat of Maryland.

The outcome left most of the Republican rank and file furious. Their leader had been toppled from within by a group most fellow House Republicans saw as unreasonable if not downright delusional about what Republicans could hope to accomplish in a divided government when Democrats control the Senate and the White House.

They credited Mr. McCarthy with trying to restore “regular order” in the usual slam-jam appropriations process, slowly producing a series of very conservative spending bills and a tough border security measure while celebrating births and mourning lost loved ones with them. When it came to the debt limit deal and the stopgap spending legislation passed with more Democratic than Republican votes that made him the target of Mr. Gaetz, his supporters said that he did what an American leader should do in that situation: protect the nation.

“He did what speakers are supposed to do,” said Representative Tom Cole, Republican of Oklahoma and a staunch McCarthy ally. “He did the right thing. He did the right thing, I think, for this institution. He showed it could function in a time of crisis. And finally, I think he did the right thing for our party.”

But in today’s Republican Party, doing the right thing is considered a transgression, not a virtue — a sign of unforgivable allegiance to the political establishment. That was the central problem for Mr. McCarthy, and for his eventual successor. House Republicans, beholden to a base that reveres former President Donald J. Trump and detests compromise, have become ungovernable. And it is doubtful that his precipitous downfall will break the fever.

There is a bloc of House Republicans who will brook no compromise even if it means shutting down the government and stirring chaos, as they wanted to do last weekend rather than accepting a spending compromise that kept the government open but excluded their priorities on border security and deep spending cuts.

The eight who brought down Mr. McCarthy are just a small fraction of the 221 Republicans who serve in the House, but they represent a broad and influential strain in the contemporary Republican Party, one that rewards lawmakers willing to confront Mr. Biden and Democrats and isn’t concerned with the consequences. Shutdown votes are good votes with that electorate.

When the next speaker defies them to strike a necessary deal with the Senate and White House, they could quickly turn on that person as well. And that is the worry on Capitol Hill, even for Democrats like Representative Steny H. Hoyer, the longtime moderate Marylander and former party leader.

“This day,” he said, “was, in part, a result of Republicans trying to accommodate a small, willful group of extreme MAGA Republican members who will not be satisfied with any compromise that can be enacted in the political context that currently exists.”