WASHINGTON — The House passed legislation by North Bay Rep. Mike Thompson to expand background checks for gun sales Wednesday, but key senators say the bill won’t go any further.

Just eight Republicans joined the Democratic majority in the 240-190 party-line vote. Two Democrats opposed the bill.

House passage was itself a victory for Thompson, a lifelong hunter and gun owner from St. Helena who has worked for more than six years to pass legislation to curtail gun violence. The Democrat’s bill would expand the requirement for background checks of gun purchasers to those buying firearms in private sales. Those would include gun shows and online sales.

Congress has not passed major gun violence prevention legislation in more than two decades, and the Senate has failed to approve measures similar to Thompson’s twice in the last 10 years. Several Democrats who won Republican-held seats in November ran pro-gun regulation campaigns, helping the party to claim the House majority.

Thompson was cheered by other members of Congress and gun-regulation advocates as they emerged from the Capitol after the bill passed.

“This is an important day. This is an important vote. This is an important piece of legislation,” Thompson said. “And if the Senate does their job, it’s going to save lives.”

But the chances of the bill becoming law are slim.

The Senate and White House are still under Republican control, and the GOP has largely opposed the idea of expanding background checks for gun sales as an infringement of the Second Amendment right to possess firearms. If all Senate Democrats voted for the bill, it would need 13 Republican votes to reach the 60-vote threshold to advance.

President Trump has not taken a position on Thompson’s bill.

“I’m still trying to find a way to get there,” said Sen. Pat Toomey, R-Pa., who has worked for years on similar legislation to Thompson’s with Sen. Joe Manchin, D-W.Va. “I can’t point to you how we get to 60. But that would be my goal. And if we could find something similar to Manchin-Toomey that got us to 60, then we could go to conference with the House and get something worked out.”

Any such bill would need to go through the Senate Judiciary Committee, whose chairman says he will not move on background checks. South Carolina GOP Sen. Lindsey Graham said he would hold hearings instead on “red flag” legislation, which would allow local law enforcement to stop people who pose a risk to themselves or others from possessing guns.

“I don’t see anything new on that front,” Graham said of previously defeated background check proposals. “To me, the red flags make the most (sense) — the problem to me is the convergence of disturbed people and guns.”

The House bill did face an unexpected last-minute hurdle, when Republicans pulled off a procedural maneuver to add controversial language.

Before passage, House rules allow the minority to offer a “motion to recommit” — an opportunity to add something to the bill that, in practice, is often intended to put the majority in a tough political position. Republicans surprised Democrats with an amendment requiring that undocumented immigrants or immigrants prohibited from buying guns be reported to Immigration and Customs Enforcement if they try to purchase one.

Democrats lost 26 members who voted with Republicans to add the language, meaning it became part of Thompson’s bill. The House then passed the overall legislation.

“It was just an effort from Republicans, who have done nothing on this for six years, to throw the proverbial monkey wrench in the system,” Thompson said. “Those motions to recommit put some people in a rough spot, and that’s what the Republicans were trying to do, and it worked 26 times.”

Thompson said a House gun violence prevention task force he chairs would consider other legislative options, including the red-flag measure, and would keep the pressure on the Senate to pass his bill.

“I don’t think it’s as much me and you as it is the millions of people across the country who want background checks expanded, and I think the senators are going to hear from their constituents,” Thompson said.

Tal Kopan is The San Francisco Chronicle’s Washington correspondent. Email: tal.kopan@sfchronicle.com Twitter: @talkopan