PHOENIX — Even before President Trump’s rise, a pair of Western states foreshadowed some of the consuming clashes of his presidency: the tug of war between traditional conservatives and border-hawk nationalists, and the struggle for power between diverse, booming cities like Las Vegas and Phoenix, and far-flung rural precincts struggling to keep up.

And in a season of political tumult, Nevada and Arizona have emerged anew as a defining battleground for both parties — states that encapsulate the evolving politics of the Southwest and may control the balance of power in the Senate.

A sequence of political quakes this year has shaken both states, most recently the divisive, futile drive to repeal the Affordable Care Act. Senator John McCain, Republican of Arizona, cast the deciding vote that doomed the effort, leaving Republican senators in both states caught in the backwash and facing fury from Democrats and Mr. Trump’s supporters alike.

In both states, Republican senators who have crossed Mr. Trump now face the wrath of his political base. Senator Dean Heller of Nevada, who made a great show of denouncing an early effort by Republicans to repeal the health care law, drew a primary contest last week from Danny Tarkanian, a frequent political candidate who has branded himself a cheerleader for the White House. Next door, Senator Jeff Flake of Arizona, who already has one Republican challenger, has faced new threats of retribution from the right after assailing Mr. Trump in a book.

Mr. Trump menaced Mr. Flake in a tweet Thursday morning, attacking him as “toxic” and hailing a far-right former state senator running against him.

“Great to see that Dr. Kelli Ward is running against Flake Jeff Flake, who is WEAK on borders, crime and a non-factor in Senate,” tweeted Mr. Trump, who plans to hold a rally in Phoenix next week.

The West looms just as large for Democrats, holding out a rare chance to pick up seats in the Senate. More than a dozen House seats are at stake across the broader region, including seats in Texas and California, along with a handful of governorships. Republicans hold a slim majority in the Senate, 52 seats to the Democrats’ 48, but the 2018 political map is tilted heavily in their favor.

Forced to defend 10 Democratic-held Senate seats in states Mr. Trump won, Democrats have settled on Mr. Heller and Mr. Flake as their best opportunities to go on offense, with Senator Ted Cruz of Texas a long-shot third target. They have rallied behind Representative Jacky Rosen of Nevada as an opponent for Mr. Heller, and Representative Kyrsten Sinema of Arizona is likely to challenge Mr. Flake, according to three Democrats briefed on her plans.

Both Mr. Flake and Mr. Heller ultimately voted for unpopular health care legislation ― Mr. Heller bending after a public working-over by the president ― and Democratic-leaning groups have already battered them with about $8 million in advertising on the issue.

Harry Reid, the former Democratic leader in the Senate, said the growing prominence of these states in 2018 portended a longer-term shift. For all the concern about Midwestern states that shifted toward Mr. Trump, it is the Sun Belt and interior West that are expected to gain population, House seats and electoral votes over the coming decades.

Interactive Feature | Sign Up for the Race/Related Newsletter Join a deep and provocative exploration of race with a diverse group of New York Times journalists.

“The power has shifted in our country, west of the Mississippi,” Mr. Reid said in an interview. “It started a couple of cycles ago, but now it’s in full force.”

But Mr. Reid said it would take intensive financial investment and political organizing by Democrats to capture new states, like Arizona or Texas, where Representative Beto O’Rourke, a Democrat, is mounting a challenge to Mr. Cruz. Mr. Reid said he had brought his chief political lieutenant, Rebecca Lambe, to address Senate Democrats after the November election, to detail how Democrats in Nevada had mobilized Latino voters and turned the state progressively bluer ― a model, he said, for the whole region.

If the Nevada race has taken shape faster, the Senate race in Arizona may express the Southwest’s political churn most fully: Mr. Flake’s candidacy embodies the Republican Party’s identity crisis, with the rift between traditional, leave-us-alone conservatives and Trump-style nationalists on vivid display. In Arizona, that division predates Mr. Trump’s ascent, emerging from battles over immigration that have convulsed the border region. Mr. Trump plans to hold a rally in Arizona next Tuesday.

Republicans outnumber Democrats in the state, and though Democrats have come close in several major elections — including Mr. Flake’s first Senate bid, in 2012, and the presidential vote last year — they have persistently fallen short. No Arizona Democrat has won a Senate seat since the fall of the Berlin Wall.

Scott Smith, the Republican former mayor of Mesa, a conservative Phoenix suburb of half a million people, said the political environment was unusually fluid because of Mr. Flake’s uncertain standing and the lack of clear leadership to organize Democrats.

“I haven’t seen this type of unsettled waters, certainly in my adult lifetime,” Mr. Smith, 61, said.

Mr. Flake, 54, who has embarked on a blitz of television appearances over the last few weeks to promote his book, “Conscience of a Conservative,” declined through a spokesman to be interviewed. Casting himself as an earnest, small-government ideologue in the mold of former Senator Barry Goldwater of Arizona, Mr. Flake has continued to chide Mr. Trump.

Mr. Trump has indicated to associates for months that he is open to opposing Mr. Flake’s renomination in the primary race. Robert Mercer, a billionaire investor supportive of Mr. Trump, has donated $300,000 to a group supporting Mr. Flake’s first challenger, Kelli Ward. Ms. Ward is a far-right former state senator.

Mr. Flake is likely to have well-funded allies of his own. Steven Law, who heads the Senate Leadership Fund, a “super PAC” backed by the Senate majority leader, Mitch McConnell of Kentucky, said Mr. Flake and Mr. Heller were high priorities for the group.

“We can’t grow our majority unless Senators Flake and Heller keep their seats, and we will do our part to make sure that happens,” Mr. Law said in an email.

But it is not just the hard right that Mr. Flake has alienated in Arizona. Republicans skeptical of Mr. Trump say the senator has not done enough to challenge the president on matters of policy making. Grant Woods, a former state attorney general who is close to Mr. McCain, said he had been dismayed by Mr. Flake’s stance on health care and posted criticism of the senator on Facebook.

“I was disappointed in his vote,” said Mr. Woods, a Republican. “I don’t appreciate a down-the-line vote with Donald Trump.”

Mr. Flake’s deepening vulnerability has stirred several potential challengers, who see 2018 as their best chance yet for a breakthrough in Arizona. Senator Chuck Schumer of New York, the Democratic minority leader in the Senate, has spoken with at least three possible recruits and has indicated to Democrats in Washington and Arizona that he believes Ms. Sinema, a centrist lawmaker, would be the strongest candidate, according to multiple Democrats briefed on the conversations.

State Representative Randy Friese, a trauma surgeon, said he, too, was leaning toward entering the race and would focus heavily on Mr. Flake’s support for the Republican health care bill. Greg Stanton, the mayor of Phoenix, has also been weighing a bid.

A spokesman for Mr. Schumer declined to comment.

Ms. Sinema stopped short of confirming that she intended to run, but said in an interview that Arizona needed a candidate to “answer the call” and fight for the state in Washington.

Ms. Sinema said a Democrat would have to campaign in a virtually nonpartisan way to win a Senate race, and she criticized national Democrats for moving too far to the left. She described liberal promises of free college and single-payer health care as “just not real.”

“It’s irresponsible to promise a platform that you can’t deliver on, and I think Arizonans also want the truth,” Ms. Sinema said. “When someone says, ‘I’m going to give you free college,’ that really makes me angry, because you’re not going to do that. You’re not going to get free college.”

Democratic and Republican leaders in Arizona say the battle for Mr. Flake’s Senate seat may help define both parties in a lasting way, shaping the larger struggle for control of the Southwest in future elections, including the 2020 presidential race.

Rebecca Rios, the Democratic leader in the Arizona House of Representatives, called the race a “golden opportunity” for long-suffering Democrats to develop a sharper agenda.

“This is an opportunity to show what we can offer and what we’re made of,” Ms. Rios said, “as opposed to just being in opposition to bad policy.”

Ms. Rios’s Republican counterpart, Speaker J. D. Mesnard, said Mr. Flake’s fate could begin to settle what it meant to be an Arizona Republican under President Trump.

“I guess I’m reserving judgment for how we define Republicanism going into the 2018 race,” Mr. Mesnard said, adding of Mr. Flake’s criticism of the president, “Obviously, he has offended a lot of people.”