Others familiar with Mr. McConnell’s thinking said his initial comments were aimed at deterring the White House from setting hard goals for passing tax cuts and establishing a timeline that might be impossible to meet. The fear is that Republicans will again get pummeled if they come up short.

Republicans note that they have very little margin for error with just 52 seats in the Senate, and even that number depends on the availability of Senator John McCain, Republican of Arizona, who is being treated for brain cancer. Some also point out that Mr. Trump bears some responsibility for the health care debacle since his hammering of Senator Lisa Murkowski, Republican of Alaska, helped alienate her. Plus, there was his past derision of Mr. McCain, who joined Ms. Murkowski and Senator Susan Collins, Republican of Maine, in stalling Mr. McConnell’s push for repeal.

Like many of his actions over the past few weeks, the president’s fusillade against Mr. McConnell seems aimed at reassuring his core supporters and shifting the blame for a lack of accomplishments from the White House to Congress — even at the expense of his fellow Republicans. It could also help appease those conservatives unhappy with Mr. Trump for endorsing Senator Luther Strange, Mr. McConnell’s chosen candidate, over two more anti-establishment Republican contenders in the coming special Senate election in Alabama.

In some respects, taking on Mr. McConnell is not that politically risky for Mr. Trump. Congressional Republican leaders have far lower approval ratings than the president, whose numbers are at a record low for this point in a first term. And Mr. McConnell has never been popular with the anti-Washington crowd of conservative Republicans who align themselves much more with Mr. Trump.

Mr. McConnell and his political team have regularly feuded with hard-right conservative groups as they have tried to unseat him and other Republican incumbents. In 2014, Mr. McConnell vowed that he intended to “crush them everywhere” and made good on that statement as he repelled the challenges from the right.

He gained a reprieve from their hostility with his machinations on the Supreme Court, winning the respect of conservatives for preserving the seat for Mr. Trump to fill even as he faced harsh criticism from Democrats. But just last month, one leading conservative activist renewed the criticism, publicly calling Mr. McConnell the “head alligator” in the Washington swamp.