INDIANAPOLIS — Indiana’s Republican-led Senate decisively rejected a redrawn congressional map Thursday that would have favored their party, defying months of pressure from President Donald Trump and delivering a stark setback to the White House ahead of next year’s midterm elections.

The vote was overwhelmingly against the proposed redistricting, with more Republicans opposing than supporting the measure, signaling the surprising limits of Trump’s influence even in one of the country’s most conservative states.

Trump has been urging Republicans all across the country to redraw their congressional maps in an unusual campaign to help the party maintain its thin majority in the House of Representatives. Although Texas, Missouri, Ohio and North Carolina went along, Indiana did not — despite cajoling and insults from the president and the possibility of primary challenges.

“The federal government should not dictate by threat or other means what should happen in our states,” said Spencer Deery, one of the Republican senators who voted no on Thursday.

When the proposal failed 31-19, cheers could be heard erupting from inside the chamber as well as shouts of “thank you!” The debate had been shadowed by the possibility of violence, and some lawmakers have received threats.

Trump tried to brush off the defeat, telling reporters in the Oval Office that he “wasn’t working on it very hard” despite his personal involvement in the pressure campaign.

Republicans could have erased two Democratic districts

The proposed map was designed to give Republicans control of all nine of Indiana’s congressional seats, up from the seven they currently hold. It would have effectively erased Indiana’s two Democrat-held districts by splitting Indianapolis among four districts that extend into rural areas, reshaping U.S. Rep. André Carson’s safe district in the city. It would have also eliminated the northwest Indiana district held by U.S. Rep. Frank Mrvan.

District boundaries are usually adjusted once a decade after a new census. But Trump has described redistricting as an existential issue for the party as Democrats push to regain power in Washington.

“If Republicans will not do what is necessary to save our Country, they will eventually lose everything to the Democrats,” Trump wrote on social media the night before the vote.

The president said anyone who voted against the plan should lose their seats. Half of Indiana senators are up for reelection next year, and the conservative organization Turning Point Action had pledged to fund campaigns against them.

Inside the state Senate chamber, Democratic lawmakers spoke out against redistricting ahead of the vote.

“Competition is healthy my friends,” Sen. Fady Qaddoura said. “Any political party on earth that cannot run and win based on the merits of its ideas is unworthy of governing.”

In the hallways outside, redistricting opponents chanted “Vote no!” and “Fair maps!” while holding signs with slogans like “Losers cheat.”