Mr. Trump accused the Democrats of pursuing a “witch hunt because they can’t beat us at the ballot.” He denied pressuring Ukraine’s president, Volodymyr Zelensky, to investigate Vice President Joseph R. Biden Jr. in return for American aid. “It’s a joke,” he declared. “Impeachment for that?”

For both men, the bravado masked a precarious future.

Mr. Johnson has lost vote after vote in Parliament since he came into office, including one aimed at forcing him to ask Brussels to delay Britain’s departure from the European Union beyond the deadline of Oct. 31 — something he has said he would rather die “in a ditch” than do. Opponents have accused him of misleading Queen Elizabeth II in asking her to suspend Parliament, and called for his resignation.

Mr. Trump said he believed he had put impeachment behind him when the special counsel, Robert S. Mueller III, issued his report on the Trump campaign’s ties to Russia. He now faces the genuine prospect of being the third president to be impeached, after Andrew Johnson and Bill Clinton.

Rather than compromise, however, both have dug in their heels, apparently calculating that an unsparing response will galvanize their political bases and allow them to ride out the current turmoil. In the process, they have used language that has stunned even those used to the cut-and-thrust of politics.

On Wednesday, Mr. Johnson said Britain should press ahead with Brexit to honor the memory of Jo Cox, a member of Parliament who was adamantly pro-European and was killed a week before the 2016 Brexit referendum by a right-wing assassin. Mr. Johnson’s own sister, Rachel, condemned his words as inflammatory.

“It was a very tasteless way of referring to the memory of a murdered M.P., murdered by someone who said, ‘Britain first,’ ” she said to Sky News.

Mr. Trump told American diplomats he wanted to hunt down the officials who gave a whistle-blower information about his call with the Ukrainian president. Anyone who did so was “close to a spy,” he said, adding, “You know what we used to do in the old days when we were smart with spies and treason, right?”