Even as President Trump’s popularity sags amid an unpopular war and soaring gas prices, his success Tuesday in ousting a group of Republican state lawmakers in Indiana who had crossed him showed that he continued to hold a viselike grip on a critical core of the Republican base.

For all the talk of divisions within the MAGA movement over the war in Iran, the results in Indiana on Tuesday showed that Mr. Trump can still inspire the kind of voters who will turn out to vote when he asks them to. In this case, it was for revenge: The challengers Mr. Trump backed defeated at least five of the seven Republicans incumbents in the Indiana Legislature who had defied his call to draw new congressional maps ahead of the midterms.

Victories in a low-turnout Republican primary do not mean that Republican fortunes are improving ahead of the midterm elections. The party still faces an uphill battle to keep control of Congress, amid intense headwinds from the unpopular Iran war and growing economic anxiety.

But in these races, Mr. Trump and his allies were able to vastly outspend the incumbents and weaponize the bully pulpit of the presidency over little-known state lawmakers. Mr. Trump posed for photos in the Oval Office with most of the challengers, giving them powerful visuals to drive home their alliance with the White House.

It can be hard to be an incumbent. Yet the results on Tuesday were so lopsided that one state senator lost by more than 50 percentage points. The results reinforced what has remained an unshakable truth over the decade of Mr. Trump’s domination of national politics: His sway over a significant part of the Republican base is immovable.

“You are next,” Chris LaCivita, Mr. Trump’s co-campaign manager in 2024, warned Representative Thomas Massie of Kentucky, a Republican who has battled with Mr. Trump, in a social media post early Wednesday. Mr. Trump wants to oust Mr. Massie in a primary later this month, and Mr. LaCivita is leading an anti-Massie super PAC.

While Mr. Trump’s overall approval rating has fallen to 39 percent, according to The New York Times polling average, it is much higher among Republicans. His approval rating with that subset held steady at 85 percent in the latest Washington Post/ABC News/Ipsos poll.

“Donald Trump has ruled the Republican Party and the Republican base, and he obviously continues to do so,” said Whit Ayres, a longtime Republican pollster. Mr. Ayres pointed to a difference between high-profile defectors such as Tucker Carlson and the average Trump voters. “While MAGA influencers and elites may have broken with the president on the war, MAGA Republicans are 100 percent, or maybe 90 percent, behind it.”

Most immediately, the romp by Mr. Trump and his allies through Indianapolis is likely to send up warning flares to Republicans across the country: Fall in line on the president’s priorities, especially on redistricting, or face the consequences.

Last week, the president moved swiftly to take advantage of a Supreme Court ruling declaring Louisiana’s House map an unconstitutional racial gerrymander. The decision effectively removed a key impediment to drawing new maps, and Mr. Trump quickly ratcheted up pressure on other Republican-led states to redraw theirs for partisan gain.

The president called up Gov. Bill Lee of Tennessee, a Republican, where legislators on Wednesday unveiled a new map to carve up the state’s only remaining district with a majority Black population. “This should give us one extra seat,” Mr. Trump wrote last week of redoing the boundaries in the state.

The president also praised Gov. Jeff Landry of Louisiana, a Republican, for postponing his state’s House elections to remake that state’s map. “Thank you Jeff, keep up the GREAT work!” he wrote on social media.

Now, the president’s allies are urging Republicans across the South to take heed of the lessons of Indiana.

“Our message to the other states is to be proactive and move quickly,” said David McIntosh, the president of the Club for Growth, which spent roughly $2 million in the push to oust Indiana state senators who had not bent to Mr. Trump’s wishes. “My hope is they see the old-fashioned style of leadership that Rod Bray” — the Indiana G.O.P. leader who bucked Mr. Trump — “brought to the table in Indiana is rejected by the voters.”

Attention is likely to shift next to South Carolina, where many Republicans in the state are looking to eliminate the lone Democratic district, held by Representative Jim Clyburn, one of the Democratic Party’s most veteran Black leaders. Such a move would require a two-thirds vote in the State Legislature to pass, with Republicans unable to spare defections.

G. Murrell Smith Jr., the speaker of the South Carolina House of Representatives, did not immediately respond to a request for comment on Wednesday. But he told reporters on Tuesday that nothing has been decided yet on redistricting, noting that lawmakers were simply voting to allow the Legislature to return after the regular session ends next week. If they vote to return, they could then begin the process of assessing if they want new maps, he said.

Gov. Henry McMaster, the Republican governor of South Carolina and a longtime Trump ally, indicated on Tuesday that he was leaving the decision up to the Legislature and would not weigh in directly. “That’s their job to study, to analyze and to make a decision whether it’s necessary or wise,” Mr. McMaster said during a news conference with reporters.

Republicans in Kansas could similarly face new pressure from the White House. There, at least 10 Republicans in the State Legislature resisted efforts to redraw the state map last year and remove the lone Democratic district.

Some in Kansas still remain opposed to calling a special session solely to draw new maps this year, even after Indiana.

“No, that isn’t any reason that I would change my mind,” said Clarke Sanders, a Republican state representative in Kansas. But Mr. Sanders said he would be open to considering drawing new maps in Kansas when the Legislature reconvenes for its regularly scheduled session next year.

Part of the power Mr. Trump holds over state legislatures lies in the political contours of these races: They’re often low turnout and attract little to no outside money. In Indiana, his allies’ flood of funds most likely made a difference.

Mr. Trump and his allies also poured roughly $9 million on ads alone in Indiana to challenge the Republican incumbents, according to AdImpact, an ad tracking firm.

A similar playbook would be easily replicable in other states, especially for Mr. Trump’s well-financed political operation and his deep-pocketed allies.

Mr. Trump’s team was intimately involved in the efforts to both raise and direct the money that was spent in Indiana, in particular James Blair, who is overseeing the political operation to keep Republican majorities in the midterms.

“We were not bluffing,” Tim Saler, a veteran of the Trump 2024 campaign who oversees data programs, wrote in a post on X, adding an ice cube emoji as the results came in on Tuesday.

With all of the might of the White House to cajole recalcitrant Republicans to fall in line, the final arbiter of Mr. Trump’s redistricting push ahead of November will most likely be the courts.

Many of the states looking to redistrict this year face significant legal hurdles. The Supreme Court ruling last week came late in the primary calendar. Multiple states, including Louisiana, Kansas, Alabama and South Carolina, have already begun absentee voting or sending ballots to overseas voters in their primary elections.