The second challenge was the charm for Fremont attorney Ro Khanna, who sailed to victory Tuesday over eight-term District 17 Congressman Mike Honda.

Immediately after polls closed, the repeat contender raced far ahead of the incumbent, building on a strong lead he tallied in June in the district that includes Santa Clara and Alameda counties.

Registrars in both counties said it was a significant chunk of the return; some mail ballots are still being counted but Khanna’s lead appears too strong to be eroded.

Late Tuesday, Honda campaign spokesman Vedant Patel said they were not ready to concede the race.

Meanwhile, Khanna campaign manager Michael Ambler said they are “confident that Ro will be the new Congressman” as the candidate thanked supporters and campaign workers at a crowded Fremont restaurant.

Larry Gerston, professor emeritus in political science at San Jose State University, said the result was “not a surprise,” and that a late-game lawsuit from the Honda camp that alleged campaign espionage failed to gain traction.

“Clearly people looked at it as throwing mud to get off topic and it didn’t sell,” he said.

He added that Khanna had been working the district, holding town hall meetings to engage directly with voters.

“By meeting people, he exploited the theme that Honda was out of touch with his constituents,” Gerston said.

This was the second time in as many years that the two Democrats squared off for the seat, an intra-party battle that pitted an aging but loyal party stalwart passionate about civil rights against a fresh younger face eager to address economic issues vital to Silicon Vallley.

Analysts predicted that the 75-year-old Honda would have a tough fight on his hands after Khanna, 40, unexpectedly took pole position in the June primary.

Honda has been plagued by an ongoing House ethics probe for more than a year, with allegations that the congressman used taxpayer funds for campaign purposes.

The 17th Congressional District — which straddles Alameda and Santa Clara counties — includes Sunnyvale, Santa Clara, Cupertino and North San Jose, stretching up through Milpitas and into Fremont and Newark in Alameda County.

The contest got increasingly ugly as the election loomed with Honda’s TV ads portraying Khanna as a smarmy Wall Street puppet and flashing eye-worm headline fragments about the computer charges. Those were met with return fire with spots portraying Honda as tired, ineffective and unethical.

When Khanna went up against Honda in 2014, more than 20 points divided the two in the primary, a gap that the challenger closed to less than 4 points by the general election. Tuesday’s returns showed a similar percentage point gain.

“Last time Honda was able inch out a winner,” Gerston said. “But this time he started out behind and there was no way to catch up.”

In other congressional races had Democratic incumbents well ahead of challengers, as was anticipated. That included Rep. Zoe Lofgren, who represents much of San Jose and the swath of Santa Clara County south toward Gilroy. On the Peninsula Rep. Jackie Speier, D-Hillsborough, whose 14th District includes most of San Mateo County, and 18th District, Rep. Anna Eshoo, D-Menlo Park, were both poised to win reelection, as were four incumbents in the East Bay: Rep. Jerry McNerney, D-Stockton; Mark DeSaulnier, D-Concord; Rep. Barbara Lee, D-Oakland; and Rep. Eric Swalwell, D-Dublin.

In the 20th District on the Central Coast, where longtime Congressman Sam Farr is departing, Democrat Jimmy Panetta was well ahead of Republican Casey Lucius. Panetta is son of former Defense Secretary and longtime Central Coast Congressman Leon Panetta.