Rep. Martha McSally Martha Elizabeth McSallyThe Hill's Campaign Report: Presidential polls tighten weeks out from Election Day Mark Kelly: Arizona Senate race winner should be sworn in 'promptly' New ABC/WaPost poll finds Trump edging Biden in Arizona, Florida MORE (R-Ariz.) won a nasty Republican Senate primary in Arizona on Tuesday, setting up a marquee fight against fellow congresswoman Kyrsten Sinema (D) that could help decide which party controls the Senate.

McSally, the GOP establishment favorite, won 51.3 percent of the primary vote with 9 percent of precincts reporting, according to a projection from The Associated Press.

ADVERTISEMENT

She beat two Republicans who ran to her right: former state Sen. Kelli Ward, who won 28.5 percent of the vote, and former Maricopa County Sheriff Joe Arpaio, who ended up with 20.2 percent.

Like other Republican primaries this year, the costly contest largely became a competition about which candidate was most closely aligned to President Trump Donald John TrumpSteele Dossier sub-source was subject of FBI counterintelligence probe Pelosi slams Trump executive order on pre-existing conditions: It 'isn't worth the paper it's signed on' Trump 'no longer angry' at Romney because of Supreme Court stance MORE, who opted not to endorse anybody in the race because of personal connections he had with all three of them.

McSally’s victory gives national Republicans a sigh of relief, boosting their hopes of retaining a Senate seat being left vacant by retiring Sen. Jeff Flake Jeffrey (Jeff) Lane FlakeHow fast population growth made Arizona a swing state Jeff Flake: Republicans 'should hold the same position' on SCOTUS vacancy as 2016 Republican former Michigan governor says he's voting for Biden MORE (R) — and one that has been in the party's hands for decades.

Trump sent a tweet congratulating McSally for her victory — while taking a dig at Flake, who has been an ardent critic of the president.

"Martha McSally, running in the Arizona Primary for U.S. Senate, was endorsed by rejected Senator Jeff Flake....and turned it down - a first! Now Martha, a great U.S. Military fighter jet pilot and highly respected member of Congress, WINS BIG. Congratulations, and on to November!" Trump wrote.

At her election night party, McSally quickly drew a contrast between her and Sinema. McSally played up her military service, while casting Sinema as an ultra-liberal to the "left of the Pelosi Democrats," referring to House Minority Leader Nancy Pelosi Nancy PelosiPelosi slams Trump executive order on pre-existing conditions: It 'isn't worth the paper it's signed on' On The Money: Anxious Democrats push for vote on COVID-19 aid | Pelosi, Mnuchin ready to restart talks | Weekly jobless claims increase | Senate treads close to shutdown deadline Trump signs largely symbolic pre-existing conditions order amid lawsuit MORE (D-Calif.). And McSally dubbed Sinema with a Trump-style nickname.

"It's a choice between a doer and a talker, between a patriot and a protester, between a career fighter pilot and a career politician," McSally said to loud cheers Tuesday night.

"Hollywood Sinema, I like to say that — Sinema with a 'C,' " she added. "She's undergone an extreme makeover, fabricating a centrist image to fulfill her ambition. She's a fake production, running on a phony script in order to fool the voters."

Many Republicans believed McSally was the only viable candidate for the general election, believing that Ward was too far to the right for Arizona's increasingly diverse electorate.

But the presence of Ward and Arpaio, both conservative firebrands, forced McSally to veer hard to the right.

Ward posed the biggest challenge, running as an immigration hard-liner and an unabashed Trump supporter. She repeatedly railed against Senate Majority Leader Mitch McConnell Addison (Mitch) Mitchell McConnellTrump 'no longer angry' at Romney because of Supreme Court stance On The Money: Anxious Democrats push for vote on COVID-19 aid | Pelosi, Mnuchin ready to restart talks | Weekly jobless claims increase | Senate treads close to shutdown deadline The Hill's Campaign Report: Trump faces backlash after not committing to peaceful transition of power MORE (R-Ky.) and the GOP establishment.

Ward also attacked McSally as “Jeff Flake 2.0” — a reflection of how much Flake's standing has fallen with fellow Republicans in the state.

McSally, a two-term congresswoman and former combat fighter pilot, also faced strong criticism from Ward for being too weak on border security and for not being a strong enough supporter of Trump’s.

McSally still hasn’t said whether she voted for Trump in 2016, but she frequently touted her backing of the president and her desire to build a border wall.

But McSally led most polls and also benefited from missteps from Ward, including a suggestion from the former state senator that the late Sen. John McCain John Sidney McCainAnalysis: Biden victory, Democratic sweep would bring biggest boost to economy The Memo: Trump's strengths complicate election picture Mark Kelly: Arizona Senate race winner should be sworn in 'promptly' MORE (R) had timed his announcement saying he was stopping his cancer treatment to hurt her campaign.

McCain, who served in the Senate for more than three decades representing Arizona, died on Saturday.

McSally now goes on to face Sinema in a high-profile match-up for a critical Senate seat. The Cook Political Report rates the Senate race as a "toss-up."

Some Republicans had been fretting that McSally was too focused on Ward and the primary, giving Sinema, a moderate Democrat who is considered a formidable opponent, a major head start.

Sinema on Tuesday defeated little-known Deedra Abboud, a civil rights attorney, in the Democratic primary. But the race was largely meaningless, and Sinema was able to cruise through most of the year without GOP attacks, while running millions of dollars in ads defining herself as an independent.

Still, few are willing to count out McSally, a top GOP recruit who is a prolific fundraiser, having raised more than $7.6 million since entering the race earlier this year.

McSally pivoted in the final days of the primary toward Sinema, running an ad criticizing the Democrat's past anti-war sentiments. The ad plays up McSally’s military service, while attacking Sinema for “protesting us in a pink tutu” after the 9/11 terrorist attacks.

Some general election polls between Sinema and McSally had the Democratic congresswoman consistently ahead. But the margin has been narrow, and the gap is expected to close as McSally — and her Republican allies — focus on the November race.

Democrats haven’t won a Senate seat in Arizona since 1988, but they feel more confident in a cycle where the headwinds will be against Republicans.

Trump won Arizona in 2016 by less than 5 points and the state is widely considered a formerly deep-red state that has become more purple over the past years.