Rep. Roger Marshall won the Senate GOP primary in Kansas on Tuesday, CNN projects, delivering the party establishment a victory that could help keep the seat in its control this November.

Marshall fought back a fierce challenge from former Kansas Secretary of State Kris Kobach, whose crusades against illegal immigration and voting fraud have made him a divisive figure.

Democrats haven't won a Senate seat in the state since 1932, the longest losing streak for the party in the country. But the Republican establishment was terrified that spell might have been broken if the state picked Kobach as its nominee.

Marshall, a two-term congressman from the "Big First" district in the central and western parts of the state, boasted the support of the man he's seeking to replace, longtime Sen. Pat Roberts, and a former occupant of his House seat, former Sen. Bob Dole. Powerful groups like the Kansas Farm Bureau, Kansans for Life and the Chamber of Commerce also backed Marshall.

But he did not have the endorsement of the man who could potentially ensure him victory: President Donald Trump. Last week, Trump indicated to associates on Air Force One that he would not publicly intervene in the race despite the wishes of top Republicans.

Marshall tweeted a video shortly after the race was called Tuesday night featuring a congratulatory call from Trump on speakerphone. The President on Wednesday morning congratulated Marshall on a "great race" and said he has his "Complete and Total Endorsement."

Marshall will face Democratic state Sen. Barbara Bollier, who has broken state fundraising records by bringing in $7.8 million, according to the latest Federal Election Commission filings.

Roberts said on Tuesday that the primary race was a "toss up."

"I don't know what is going to happen," he said.

Kobach's Republican critics warned that only he could put the seat at risk, pointing to the outcome of the 2018 gubernatorial race. Trump endorsed Kobach a day before that Republican primary, which Kobach won by only 343 votes. He then lost to Democrat Laura Kelly by 5 points, even though Trump won Kansas by 20 points in 2016.

Those critics said that Kobach emphasized issues that did not meet the moment, while Kelly zeroed in on overturning the state's education cuts and reversing the budget shortfall left behind by former Republican Gov. Sam Brownback. They also noted that Kobach is a weak fundraiser.

But Kobach has argued that while Democrats have recently won statewide offices in Kansas, they've consistently failed to reach the Senate, where the debated issues are different and views of the national parties hold more sway.

In the 2020 campaign, both Kobach and Marshall have aired ads from Trump's 2018 rally in Topeka, in which the President calls Kobach a "tireless champion for border security" and Marshall a "great friend."

But outside groups have deluged the airways with ads, even outspending the candidates in seeking to pick their preferred nominee.

A Democratic-aligned organization called the Sunflower State has spent over $4.6 million on ads boosting Kobach, calling him "too conservative" and Marshall "soft on Trump." Meanwhile the Republican-affiliated group Plains PAC has spent over $3.3 million bashing Kobach for his alleged "ties to white nationalists," a charge his campaign strongly denied. And Senate Leadership Fund, which is aligned with Senate Majority Leader Mitch McConnell, has also spent over $1.8 million supporting Marshall, a OB-GYN doctor.

Of the nine other Republicans running in the race, Bob Hamilton, who owns a plumbing company, is the biggest wild card. His campaign has spent more than $2.5 million on advertising, more than Kobach's and Marshall's campaigns. One ad shows Hamilton water-skiing, holding the American flag, as a man in a boat touts him as a "crazy, Trump-supporting, American-loving, flag-waving conservative."

"Kobach can't win," says the man. "And Marshall? He's one hot mess, moderate squish."

But on Tuesday, Hamilton earned the third-most votes, potentially taking some away from Kobach and helping Marshall win.

This story has been updated with additional developments Tuesday.