Gavin Newsom, the Democratic lieutenant governor and former mayor of San Francisco, took photos with voters in Oakland on Tuesday.

LOS ANGELES — Gavin Newsom, the Democratic lieutenant governor and former mayor of San Francisco, took a major step Tuesday in his bid to become California’s next governor, capturing one of two spots on the November ballot as the state moved closer to the end of the era of Gov. Jerry Brown, according to The Associated Press.

The fight for the second spot in the general election was between Antonio R. Villaraigosa, a Democrat and former Los Angeles mayor, and John Cox, a Republican business executive whose campaign was lifted by an endorsement from President Trump, who reiterated his support with a tweet as voters were heading to the polls on Tuesday morning.

But the results were more muddled in the most-watched races here: Seven congressional districts, carried by Hillary Clinton in 2016 and now held by Republicans, that Democrats are aiming to capture this November — a linchpin of their strategy to take back control of the House.

[Here are results from New Jersey and the other states that voted Tuesday.]

In at least three of those races, Democrats were battling to avoid getting shut out from the November ballot under California’s “top two” election system: The two leading vote-getters, regardless of party, will go on to face each other in November. The races appear to be close, and provisional ballots and votes sent by mail could be critical and take days to count.

In the race for U.S. Senate, Dianne Feinstein easily won a spot on the November ballot in what by every indication looks like an easy race this fall — no matter who ends up running against her.

California may be the single most important battleground for Democrats in their drive to claim a majority in Congress. President Trump is intensely unpopular in the state, and broad backlash against his administration could help Democrats seize perhaps a third of the seats they need to regain power.

Yet California’s unusual open-primary system has become a difficult obstacle for Democrats, as a horde of candidates on the left have divided up Democratic votes and threatened to let Republicans monopolize the general election.

Republicans have raced to avert a shutout of their own in the governor’s race. Washington Republicans — including Mr. Trump and Kevin McCarthy, the House majority leader — had been eager to boost Mr. Cox into a fight with Mr. Newsom, to head off the possibility that no Republican would be on the top of the November ballot. That could dampen Republican turnout in a year when Democrats are making their all-out effort to capture more than half a dozen Republican-held seats.

Voting took place across the state under a cloud of confusion as voters tried to navigate their way through the top two system. And in a potentially unnerving sign for some Democrats, the Los Angeles County clerk revealed Tuesday night that a printing error had improperly left about 119,000 names off voting rosters in the area — a development that Mr. Villaraigosa called “infuriating” as he urged affected voters to cast provisional ballots.

“Tonight is going to be a long night,” Mr. Villaraigosa told supporters after the polls closed, pledging to find out the reason for the names being left off the rolls. “I think when you’re the leader, you’ve got to calm the water, so we’re not casting aspersions.” he added. “We’re not saying that something nefarious happened.”

Antonio Villaraigosa, the former Los Angeles mayor, had positioned himself as more of a moderate than Mr. Newsom.

Earlier in the day, at Laguna Beach City Hall, Aggie Dougherty had to thumb through the sample ballot packet she carried with her to remember which Democrat she had chosen after more than a dozen candidates inundated the 48th Congressional District with campaign material in their bid to unseat. Dana Rohrabacher, a particularly embattled Republican.

Ms. Dougherty, 67, a bookkeeper, settled on Harley Rouda, the candidate endorsed by the Democratic Congressional Campaign Committee. Still, as she went into the voting booth, she realized she had to…