MISSOULA, Mont. — President Trump praised a Republican candidate’s assault last year on a reporter and fumed over his Democratic opponents here on Thursday night in a freewheeling rally meant to mobilize his base’s support in the coming midterm elections.

“I had heard he body-slammed a reporter,” Mr. Trump said, noting that he was initially concerned that Mr. Gianforte would lose in a special election last May. “I said, ‘Wait a minute. I know Montana pretty well; I think it might help him.’ And it did.”

“Anybody that can do a body-slam,” the president added, “that’s my kind of guy.”

Mr. Trump made no mention at the rally of Jamal Khashoggi, a dissident Saudi journalist and columnist for The Washington Post, who disappeared this month after visiting the Saudi Consulate in Istanbul. United States intelligence officials say Mr. Khashoggi was most likely killed by Saudi officials.

Backlash against the president over his attacks on the news media and over his administration’s mild response to allegations that the Saudi government orchestrated the killing has been swift.

Supporters at the rally on Thursday. Mr. Trump ultimately returned to the campaign message that he is likely to use as he spends the rest of the week campaigning for Republicans in the West.CreditDoug Mills/The New York Times

“To celebrate an attack on a journalist who was simply doing his job is an attack on the First Amendment by someone who has taken an oath to defend it,” said John Mulholland, the editor of The Guardian U.S. “In the aftermath of the murder of Jamal Khashoggi, it runs the risk of inviting other assaults on journalists both here and across the world where they often face far greater threats.”

Mr. Trump’s recent campaign blitz is part of a broader effort to establish support for Republican midterm candidates. At the rally, the president portrayed votes for Mr. Gianforte; Matt Rosendale, who is running for Senate; and other candidates here as a referendum on his first 21 months in office and as insurance that his policies can continue unhindered.

But Mr. Trump frequently veered off topic: He mounted a defense against the special counsel’s investigation into Russian election interference; he relitigated both his election victory and the bitter fight to confirm Justice Brett M. Kavanaugh to the Supreme Court; and he dismissed the idea that Russia interfered in the 2016 election to help his campaign. (Intelligence officials have indicted a number of Russian officials and companies for doing so.)

“Can you imagine me saying, ‘Gee, let’s call the Russians’?” Mr. Trump said, speaking as the sun set over the Minuteman Aviation hangar here in Missoula. “If I ever call the Russians, the first ones to know would be the state of Montana, and they wouldn’t be too happy about it.”

But Mr. Trump ultimately returned to the message that he is likely to use as he spends the rest of the week campaigning for Republicans in the West.

“It’s an election of Kavanaugh, the caravan, law and order and common sense,” the president told the crowd, singling out the Kavanaugh nomination battle and a caravan of migrants making its way toward Mexico and the United States.

The Senate election here in Montana, a state he won comfortably in 2016, he said, also serves as vengeance for his personal vendetta against Senator Jon Tester, a Democrat, who was among the first to raise concerns in April about Mr. Trump’s nominee for secretary of veterans affairs, Dr. Ronny L. Jackson.

“I’m here because I can never forget what Jon Tester did to a man who’s of the highest quality,” Mr. Trump said, again targeting Mr. Tester as the catalyst for the failed nomination of Dr. Jackson. “So I got to come, and I got to help, because what he did was unfair.”