“They’re all gone,” he added, “but there’s a lingering stench, and we’re going to get rid of that, too.” His remarks capped a week in which he ratcheted up complaints about Attorney General Jeff Sessions, casting some federal law enforcement officers as a “cancer on the country.”

Mr. Trump came here, to a state he won by 19 percentage points in 2016, to boost Josh Hawley, the Republican attorney general who is challenging Senator Claire McCaskill, a Democrat, in a race that Republicans regard as one of their best opportunities this year to pick up a Democratic seat. Polls show the two in a statistical tie, and the outcome could be critical in determining who controls the Senate, where Republicans hold a 51-to-49 edge.

But the event, like all of the campaign stops the president has held across the country in the run-up to the midterm elections, looked and sounded more like a boisterous re-election pep rally for Mr. Trump himself than a well-coordinated effort to lift the candidate.

“Get out in 2018, because you’re voting for me in 2018,” Mr. Trump told thousands of supporters in the JQH Arena, on the campus of Missouri State University. “They aren’t just extreme,” he said of Democrats. “They are frankly dangerous, and they are crazy.”

Mr. Hawley had only five minutes at the lectern, which he spent effusively praising Mr. Trump and savaging Ms. McCaskill for not being supportive of him. He criticized the senator for mocking the president’s vows to build a border wall, for opposing the tax cut Mr. Trump pushed through, and for coming out in opposition to Judge Brett M. Kavanaugh, the Supreme Court nominee who is facing an accusation of sexual assault.