WASHINGTON – As primary results trickled in Wednesday, Democrats and Republicans alike appeared to have dodged disaster in California.

The state’s unusual top-two primary system — which sends the top two finishers to the general election, regardless of their party — had generated fear in both parties of an electoral shutout, leaving them off the November ballot.

That was the outcome in the Senate primary, won by two Democrats, Sen. Dianne Feinstein and state Sen. Kevin de León, who will compete in the fall.

But California voters still delivered key wins for both parties.

Republican John Cox, a business executive backed by President Trump, prevailed over former Los Angeles Mayor Antonio Villaraigosa, a Democrat, for the second slot in the state’s gubernatorial race. Cox will be up against Lt. Gov. Gavin Newsom, a Democrat and former San Francisco mayor, who came in first in the primary.

And Democratic House candidates were on track to avoid shutouts in districts that are key to Democrats' chances to win majority control of the House of Representatives.

California was one of eight states on Tuesday night to hold primaries, including many that rewarded women candidates. But the Golden State is critical to Democrats, who need a net gain of 23 seats to win control of the House. They are targeting seven of the state's districts held by Republicans that former presidential candidate Hillary Clinton won in 2016.

On Wednesday, Trump tweeted his congratulations to Cox, hailing the “Trump impact” on the gubernatorial race. Cox picked up steam with Republicans after receiving Trump's endorsement last month.

“So much for the big Blue Wave, it may be a big Red Wave,” Trump tweeted.

But Newsom apparently sees the advantage of tying Cox to the president in this blue state. On Tuesday, he was already calling him a "footsoldier" in Trump's "war in California," the Sacramento Bee reported.

They are running to replace Democratic Gov. Jerry Brown, who is term limited.

Cox isn’t expected to win in November, but his position on the ballot could help Republicans in down-ballot races.

“There’s more of a reason for Republican voters to come out and therefore have that down-ballot effect,” said Mindy Romero, director of the California Civic Engagement Project at the University of California-Davis.

Another positive sign for Republicans was the recall of a Democratic state senator over a gas tax increase he supported. A measure to repeal the tax increase is expected to be on the November ballot.

“That was a pretty significant win for the Republicans, and it indicates the issue of the gas tax has some traction with the voters,” Pitney said.

Votes were still being counted in some of the California's congressional races Wednesday, but concerns about Democrats not being on the November ballot were subsiding.

A Democrat and Republican in the 39th District, which Clinton won by more than 8 percentage points in 2016, will be on the ballot for the seat that was considered the biggest lockout risk for Democrats. Republican Young Kim, a former assemblywoman, took the lead and will face Democrat Gil Cisneros, a former Navy officer and winner of a $266 million lottery jackpot who became a philanthropist, in their bids to replace GOP Rep. Ed Royce, who is retiring.

For the second cycle in a row, California Democrats shut out Republicans in a Senate primary — but the general election isn’t expected to be any less contentious.

Feinstein, a Democrat now in her fourth term, took the lead in her primary, as expected. Feinstein, who was not endorsed by the state party this year, has faced criticism from liberal activists after she suggested she could work with the Trump administration.