Bashed and battered by the toughest race of his congressional career, an upbeat Rep. Mike Honda of San Jose claimed victory Friday over fellow Democrat Ro Khanna.

Khanna conceded later in the day, calling Honda to congratulate him on his victory.

Speaking at his headquarters in a nondescript Newark storefront next to a discount shoe store and a Chinese restaurant, the 73-year-old Honda both thanked his supporters and slammed Khanna, a 38-year-old patent attorney who argued that he could better represent the high-tech interests of the Silicon Valley district.

“We sent out a message that the voters of this district value a lifetime of service to the community more than a lifetime of serving oneself,” Honda said. “You cannot buy grass roots. You could not buy it this year, and you will not be able to buy it next year, either. This district and our democracy is not for sale.”

Thousands of votes remained to be counted in the district, which spreads from Fremont through part of San Jose and over to Santa Clara, Cupertino and Sunnyvale, but both candidates agreed it would be impossible to reverse the congressman’s 4,000-plus vote lead.

Speaking to supporters at his Fremont campaign headquarters, Khanna thanked his staff and volunteers and said he had called Honda and “wished him well as he returns to Washington for another term.”

“This long campaign has come to a close,” Khanna said. “I believe, more than ever, that our district has so much to offer in building a fair and prosperous economic future for our nation in the 21st century. Our work is just beginning.”

Khanna’s courteous concession came after a campaign neither side would describe as gracious. Before and after Honda won the June primary by 20 percentage points, Khanna conducted a nonstop attack against the former schoolteacher, who has been in public office since he was elected to the San Jose Unified School District board in 1981.

Khanna painted Honda as a do-nothing congressman whom time had passed by and touted himself as someone more in tune with the needs of the tech-friendly district.

With the endorsement and financial support of many well-known tech executives, Khanna and his supporters spent more than $5 million on the race, double what Honda raised.

But much of that money was spent early in an effort to introduce the little-known Fremont resident to voters. And when Honda, buoyed by support from the state Democratic Party and big-name Democrats like President Obama and Gov. Jerry Brown, pumped campaign cash into TV ads attacking Khanna during the final two weeks of the campaign, the challenger did not have enough money for a serious response.

“We conserved our response for when we thought it would make the most difference, when people were really paying attention,” said Videk Kembaiyan, a spokesman for Honda’s campaign. “We drew a sharp contrast with Khanna, showing what (Honda) has done and what he stands for.”

Unlike Khanna, who focused his campaign on the need to build support in Washington for Silicon Valley’s tech industry, Honda appealed to the wider grass roots, to people who may have been left behind despite the district’s high-tech boom.

“Even those involved in the tech industry have greater interests beyond their jobs, dealing with the larger community,” Honda said. “I want to see everyone who lives in the valley share in the prosperity of the valley.”

Khanna’s message was that “Honda is a nice guy, but it’s time for a change,” the congressman said mockingly.

“But there’s a whole spectrum of issues in the district, and we have to care about everybody,” Honda said. “So we took that issue to the people.”

Honda will be returning to Washington for his eighth term, but he’s not thinking about retirement.

“Not for this boy yet,” Honda said. He added, however, that now that the campaign is finally over, “I will find some time for surf fishing.”

John Wildermuth is

a San Francisco Chronicle staff writer. E-mail: Twitter: @jfwildermuth