WASHINGTON — Rep. Martha McSally handily defeated former Sheriff Joe Arpaio and Kelli Ward in the Arizona Republican Senate primary on Tuesday night, setting the stage for a November battle over a seat that could determine control of the Senate, NBC News projects.

McSally, a former fighter pilot, had been favored to prevail over the two conservatives, who split the anti-establishment vote. But McSally tacked to the right in the primary, which could cause problems for her in what is expected to be a tough race against Democrat Kyrsten Sinema in November.

McSally had 51.4 percent, or 196,452 votes, to Ward's 28.6 percent, or 109,105 votes, and Arpaio's 20 percent, or 76,517 votes, with 58 percent of precincts reporting.

Republican officials had worried that Ward or Arpaio would be unelectable in November, potentially costing the GOP a Senate seat. Despite both of the challengers accusing McSally of being too moderate, she's on track to win more votes than both of her challengers combined.

Ward lost a nasty primary against Sen. John McCain in 2016, and returned this year to challenge Sen. Jeff Flake, R-Ariz. But when Flake decided not to run for reelection and Arpaio got in, Ward had a tougher time consolidating the pro-Trump conservative vote. President Donald Trump did not endorse in the race.

But he did offer McSally his congratulations in a tweet sent after midnight.

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! — Donald J. Trump (@realDonaldTrump) August 29, 2018

McSally, for her part, tweeted from her campaign account that she was "humbled and honored" to have won.

I am humbled and honored to stand before you, for the very first time, as your Republican nominee for the United States Senate. pic.twitter.com/ZM2GjLet8Z — McSally For Senate (@MarthaMcSally) August 29, 2018

In the final days of her campaign, Ward launched a bus tour with Pizzagate conspiracy theorist Mike Cernovich, and wondered aloud on Facebook if McCain's family timed their decision to announce the senator had stopped medical treatment for cancer in order to overshadow her campaign.

Former Sheriff Joe Arpaio speaks with John Lombardi as Arpaio campaigns in his bid to become the Republican nominee for an open U.S. Senate seat in Wickenburg, Arizona on August 24, 2018. Conor Ralph / Reuters file

Arpaio, meanwhile, struggled to gain any real traction, despite tying himself closely to Trump, who pardoned the former Maricopa County Sheriff after he was convicted of criminal contempt. And his disappointing third-place finish will likely mark the end of the 86-year-old's political career.

The result could influence Republican Gov. Doug Ducey, who is also up for reelection this year, as he decides whom to appoint to fill McCain's seat. The appointee will not face voters until 2020.

Arizona Democrats like their gubernatorial nominee, former state education official David Garcia, and think he has a chance to win despite the state's Republican tilt thanks to Democratic energy and concerns about public education funding.

Meanwhile, Sinema, a Democratic congresswoman from the Phoenix suburbs, ran essentially unopposed for her party's Senate nomination.

Rep. Kyrsten Sinema, D-Ariz., talks to campaign volunteers at a Democratic campaign office on primary election day, in Phoenix on Aug. 28, 2018. Ross D. Franklin / AP

Arizona hasn't elected a Democratic senator in 30 years, but changing demographics makes it more competitive and it is now viewed as one of Senate Democrats' few pickup opportunities in November. Hillary Clinton came within 4 percentage points of Trump in the state.

McSally has already started running ads attacking Sinema for "protesting us in a pink tutu" while McSally was flying combat missions in Afghanistan.

Meanwhile, former Arizona Democratic Rep. Ann Kirkpatrick was leading in her bid to make it back to Congress. Her opponent, Matt Heinz, a doctor who ran for the seat before, has not made it easy, comparing Kirkpatrick's political ambition to a "meth addiction." With 59 percent of precincts reporting, Kirkpatrick has a comfortable 10-point lead.