WASHINGTON — On one end of Pennsylvania Avenue this week, President Trump and his closest advisers labored to beat back perceptions, fueled by an anonymous essay in The New York Times and a bruising new book by Bob Woodward, that he had all but lost control of the presidency from within. He lashed out anew at his attorney general, shouted “TREASON” and demanded investigations of his detractors.

But as he raged, Republicans in the Senate were pressing steadily through angry liberal protests and Democratic perjury traps toward perhaps the most lasting impact of the Trump era: a conservative shift in the balance of the Supreme Court capable of shaping the country for a generation.

The dueling images of a president on the edge and a conservative Congress soldiering forward explain succinctly why almost all elected Republicans here have quietly supported Mr. Trump through his travails — or at least not chastised him too loudly. The payoffs for what Senator Jeff Flake, Republican of Arizona, called the party’s “Faustian bargain” have been rich and long awaited: deep cuts in corporate and personal tax rates, confirmation of a wave of conservative judges for the lower courts, and soon an ideological shift in the highest court of the land.

“Process and personality is what we are talking about — how they do things, how dysfunctional it is and how off the rails he can be,” said Senator Lindsey Graham, Republican of South Carolina, conceding that Mr. Trump was “a handful.” But, he said, “what I am talking about is results.”