Republican businessman John Cox has been projected as the second-place finisher in the California primary for governor, securing a slot at the top of the ticket on the November ballot and lifting GOP hopes to retain Congress.

The major news networks made the call with just a small percentage of the vote counted, thanks to a surprisingly strong result from Cox, who far out-performed his poll numbers.

With just 17.2% of precincts partially reporting as of 10:04 p.m. Pacific Daylight Time, Cox had 26.0% of the vote, behind Lt. Gov. Gavin Newsom’s 35.1% and far ahead of former Los Angeles mayor Antonio Villaraigosa’s 11.1%, as well as conservative Assemblyman Travis Allen (R-Huntington Beach), who had 10.9%.

The final RealClearPolitics average of polls had Cox at just 17.5%.

Cox appears to have benefited from an endorsement from President Donald Trump. He also spent heavily in the early months of the race, boosting his name recognition and convincing observers he was the GOP’s only hope. Newsroom’s campaign also boosted Cox, fearing an expensive battle against Villaraigosa in the general election.

The gubernatorial race was once thought to be a guaranteed all-Democrat fight between Newsom and Villaraigosa. Under California’s “top two” or “jungle” primary system, the top vote-winners in the primary advance, regardless of party. The conventional wisdom was that Villaraigosa would turn out the Latino vote and surpass any GOP rivals. Special interests began placing multimillion-dollar bets on that outcome, using the Newsom-Villaraigosa race as a proxy for a battle over school reform, for example. Democrats hoped that race would boost downticket candidates.

But Republicans, led by Allen and others, began organizing a statewide effort to put a repeal of California’s new gas tax on the November ballot. Then Attorney General Jeff Sessions arrived in Sacramento in early March, armed with a federal lawsuit against California’s new “sanctuary state” laws. That inspired conservative activists to mount a revolt against those laws in local governments throughout Southern California. Cox and Allen saw their polls rise.

With a Republican now competing in the most important statewide election, the GOP believes it can turn out its vote in November and protect vulnerable members of Congress in districts that voted for Hillary Clinton in 2016. That, in turn, will make it much more difficult for Democrats to pick up the 23 seats they need nationwide to win back control of the U.S. House of Representatives and to put former Speaker Nancy Pelosi (D-CA) back in power.

Villaraigosa struggled to gain traction in the polls. He was also hurt by errors in the voter rolls in L.A. County, which accidentally excluded nearly 120,000 people, many of whom had to cast provisional ballots, and some of whom may not have been able to vote at all. Villaraigosa called on officials to extend voting through Friday.

Republicans appeared to qualify for the general election in several other statewide races, but not for insurance commissioner, where former Republican Steve Poizner won the primary as a “no party preference” candidate. The race for second in the primary for U.S. Senate was neck-and-neck between Republican James Bradley and State Sen. Kevin de Léon (D-Los Angeles); incumbent Sen. Dianne Feinstein (D-CA) came in first place easily.

Joel B. Pollak is Senior Editor-at-Large at Breitbart News. He was named to Forward’s 50 “most influential” Jews in 2017. He is the co-author of How Trump Won: The Inside Story of a Revolution, which is available from Regnery. Follow him on Twitter at @joelpollak.