In the days after the Jan. 6 attack on the Capitol building, the two top Republicans in Congress, Representative Kevin McCarthy and Senator Mitch McConnell, told associates they believed President Trump was responsible for inciting the deadly riot and vowed to drive him from politics.

Mr. McCarthy went so far as to say he would push Mr. Trump to resign immediately: “I’ve had it with this guy,” he told a group of Republican leaders.

But within weeks both men backed off an all-out fight with Mr. Trump because they feared retribution from him and his political movement. Their drive to act faded fast as it became clear it would mean difficult votes that would put them at odds with most of their colleagues.

“I didn’t get to be leader by voting with five people in the conference,” Mr. McConnell, the Senate Republican leader, told a friend.

The confidential expressions of outrage from Mr. McCarthy and Mr. McConnell, which have not been previously reported, illustrate the immense gulf between what Republican leaders say privately about Mr. Trump and their public deference to a man whose hold on the party has gone virtually unchallenged for half a decade.

The leaders’ swift retreat in January 2021 represented a capitulation at a moment of extraordinary political weakness for Mr. Trump — perhaps the last and best chance for mainstream Republicans to reclaim control of their party from a leader who had stoked an insurrection against American democracy itself.

This account of the private discussions among Republican leaders in the days after the Jan. 6 attack is adapted from a new book, “This Will Not Pass: Trump, Biden and the Battle for America’s Future,” which draws on hundreds of interviews with lawmakers and officials, and contemporaneous records of pivotal moments in the 2020 presidential campaign.

Mr. McConnell’s office declined to comment. Mark Bednar, a spokesman for Mr. McCarthy, denied that the Republican leader told colleagues he would push Mr. Trump to leave office. “McCarthy never said he’d call Trump to say he should resign,” Mr. Bednar said.

No one embodies the stark accommodation to Mr. Trump more than Mr. McCarthy, a 57-year-old Californian who has long had his sights set on becoming speaker of the House. In public after Jan. 6, Mr. McCarthy issued a careful rebuke of Mr. Trump, saying that he “bears responsibility” for the mob that tried to stop Congress from officially certifying the president’s loss. But he declined to condemn him in sterner language.

In private, Mr. McCarthy went much further.

On a phone call with several other top House Republicans on Jan. 8, Mr. McCarthy said Mr. Trump’s conduct on Jan. 6 had been “atrocious and totally wrong.” He faulted the president for “inciting people” to attack the Capitol, saying that Mr. Trump’s remarks at a rally on the National Mall that day were “not right by any shape or any form.”

During that conversation, Mr. McCarthy inquired about the mechanism for invoking the 25th Amendment — the process whereby the vice president and members of the cabinet can remove a president from office — before concluding that was not a viable option. Mr. McCarthy, who was among those who objected to the election results, was uncertain and indecisive, fretting that the Democratic drive to impeach Mr. Trump would “put more fuel on the fire” of the country’s divisions.

But Mr. McCarthy’s resolve seemed to harden as the gravity of the attack — and the potential political fallout for his party — sank in. Two members of Mr. Trump’s cabinet had quit their posts after the attack and several moderate Republican governors had called for the president’s resignation. Video clips of the riot kept surfacing online, making the raw brutality of the attack ever more vivid in the public mind.

On Jan. 10, Mr. McCarthy spoke again with the leadership team and this time he had a plan in mind.

The Democrats were driving hard at an impeachment resolution, Mr. McCarthy said, and they would have the votes to pass it. Now he planned to call Mr. Trump and tell him it was time for him to go.

“What he did is unacceptable. Nobody can defend that and nobody should defend it,” he told the group.

Mr. McCarthy said he would tell Mr. Trump of the impeachment resolution: “I think this will pass, and it would be my recommendation you should resign.”

He acknowledged it was unlikely Mr. Trump would follow that suggestion.

Mr. McCarthy spent the four years of Mr. Trump’s presidency as one of the White House’s most obedient supporters in Congress. Since Mr. Trump’s defeat, Mr. McCarthy has appeased far-right members of the House, some of whom are close to the former president. Mr. McCarthy may need their support to become speaker, a vote that could come as soon as next year if the G.O.P. claims the House in November.

But in a brief window after the storming of the Capitol, Mr. McCarthy contemplated a total break with Mr. Trump and his most extreme supporters.

During the same Jan. 10 conversation when he said he would call on Mr. Trump to resign, Mr. McCarthy told other G.O.P. leaders he wished the big tech companies would strip some Republican lawmakers of their social media accounts, as Twitter and Facebook had done with Mr. Trump. Members such as Lauren Boebert of Colorado had done so much to stoke paranoia about the 2020 election and made offensive comments online about the Capitol attack.

“We can’t put up with that,” Mr. McCarthy said, adding, “Can’t they take their Twitter accounts away, too?”

Mr. McCarthy “never said that particular members should be removed from Twitter,” Mr. Bednar said.

Other Republican leaders in the House agreed with Mr. McCarthy that the president’s behavior deserved swift punishment. Representative Steve Scalise of Louisiana, the second-ranking House Republican, said on one call that it was time for the G.O.P. to contemplate a “post-Trump Republican House,” while Representative Tom Emmer of Minnesota, the head of the party’s House campaign committee, suggested censuring Mr. Trump.

Yet none of the men followed through on their tough talk in those private conversations.

In the following days, Mr. McCarthy heard from some Republican lawmakers who advised against confronting Mr. Trump. In one group conversation, Representative Bill Johnson of Ohio cautioned that conservative voters back home “go ballistic” in response to criticism of Mr. Trump, demanding that Republicans instead train their denunciations on Democrats, such as Hillary Clinton and Hunter Biden.

“I’m just telling you that that’s the kind of thing that we’re dealing with, with our base,” Mr. Johnson said.

When only 10 House Republicans joined with Democrats to support impeaching Mr. Trump on Jan. 13, the message to Mr. McCarthy was clear.

By the end of the month, he was pursuing a rapprochement with Mr. Trump, visiting him at Mar-a-Lago and posing for a photograph. (“I didn’t know they were going to take a picture,” Mr. McCarthy said, somewhat apologetically, to one frustrated lawmaker.)

Mr. McCarthy has never repeated his denunciations of Mr. Trump, instead offering a tortured claim that the real responsibility for Jan. 6 lies with security officials and Democratic legislative leaders for inadequately defending the Capitol complex.

In the Senate, Mr. McConnell’s reversal was no less revealing. Late on the night of Jan. 6, Mr. McConnell predicted to associates that his party would soon break sharply with Mr. Trump and his acolytes; the Republican leader even asked a reporter in the Capitol for information about whether the cabinet might really pursue the 25th Amendment.

When that did not materialize, Mr. McConnell’s thoughts turned to impeachment.

On Monday, Jan. 11, Mr. McConnell met over lunch in Kentucky with two longtime advisers, Terry Carmack and Scott Jennings. Feasting on Chick-fil-A in Mr. Jennings’s Louisville office, the Senate Republican leader predicted Mr. Trump’s imminent political demise.

“The Democrats are going to take care of the son of a bitch for us,” Mr. McConnell said, referring to the imminent impeachment vote in the House.

Once the House impeached Mr. Trump, it would take a two-thirds vote of the Senate to convict him. That would require the votes of all 50 Democrats and at least 17 Republicans in the Senate — a tall order, given that Mr. Trump’s first impeachment trial in 2020 had ended with just one Republican senator, Mitt Romney of Utah, voting in favor of conviction.

But Mr. McConnell knew the Senate math as well as anyone and he told his advisers he expected a robust bipartisan vote for conviction. After that, Congress could then bar Mr. Trump from ever holding public office again.

The president’s behavior on Jan. 6 had been utterly beyond the pale, Mr. McConnell said. “If this isn’t impeachable, I don’t know what is,” he said.

In private, at least, Mr. McConnell sounded as if he might be among the Republicans who would vote to convict. Several senior Republicans, including John Thune of South Dakota and Rob Portman of Ohio, told confidants that Mr. McConnell was leaning that way.

Chuck Schumer, the Senate Democratic leader, privately told the leaders of several liberal advocacy groups that he believed his Republican counterpart was angry enough to go to war with Mr. Trump.

“I don’t trust him, and I would not count on it,” Mr. Schumer said of Mr. McConnell. “But you never know.”

Mr. Schumer was right to be skeptical: Once the proceedings against Mr. Trump moved from the House to the Senate, Mr. McConnell took the measure of Republican senators and concluded that there was little appetite for open battle with a man who remained — much to Mr. McConnell’s surprise — the most popular Republican in the country.

After Mr. Trump left office, a new legal argument emerged among Senate Republicans, offering them an escape hatch from a conflict few of them wanted: It was inappropriate to proceed with impeachment against a former president, they said. When Senator Rand Paul, a fellow Kentuckian, proposed a resolution laying out the argument, Mr. McConnell voted in favor of it along with the vast majority of Senate Republicans. He didn’t ascend to power by siding with the minority, he explained to a friend.

In February, Mr. McConnell voted to acquit Mr. Trump even as seven other Senate Republicans joined with Democrats to muster the largest bipartisan vote ever in favor of conviction in a presidential impeachment trial. Anxious not to be seen as surrendering to Mr. Trump, Mr. McConnell went to the Senate floor after the vote to deliver a scorching speech against the former president.

But Mr. McConnell went mostly silent about Mr. Trump after that point. He avoids reporters’ questions about the former president and only rarely speaks about Jan. 6. In a Fox News interview in late February 2021, Mr. McConnell was asked whether he would support Mr. Trump in 2024 if the former president again became the G.O.P. nominee for the presidency.

Mr. McConnell answered: “Absolutely.”