WASHINGTON (Reuters) - The U.S. Senate passed legislation on Wednesday aimed at penalizing website operators that facilitate online sex trafficking, chipping away at a bedrock legal shield for the technology industry.

Slideshow ( 2 images )

The bill passed the House of Representatives last month and was expected to be signed into law as soon as this week by President Donald Trump.

The legislation, which passed the Senate on a 97-2 vote, would make it easier for state prosecutors and sex-trafficking victims to sue social media networks, advertisers and others that failed to keep exploitative material off their platforms.

Law enforcement has lobbied for years for such a law, an effort which resulted in part from a crackdown on backpage.com, the second largest U.S. classified ad service and which is used for sex advertising.

Passage of the bill represented a rare defeat for the internet industry, which despite coming under renewed scrutiny for how companies protect user data or guard against Russian meddling has for years avoided meaningful regulation in Washington.

Silicon Valley long opposed efforts to rewrite the decades-old Communications Decency Act, which protects companies from liability for content posted by their users and has long been credited for helping Silicon Valley’s rapid growth over the past 20 years.

But supporters of the bill said that part of the law, known as Section 230, has been too broadly used to protect websites like backpage.com.

The Supreme Court in January 2017 refused to consider reviving a lawsuit against backpage.com that was filed by three young women who claimed that the website facilitated their forced prostitution, letting stand a lower court ruling because of the protection afforded by the Communications Decency Act.

“Today’s vote is a victory for trafficking survivors and a victory for our efforts to help stop the selling of women and children online,” said Republican Senator Rob Portman, an original sponsor of the bill, the Stop Enabling Sex Traffickers Act.

Facebook Inc and other technology companies and influence groups largely withdrew opposition to the measure in recent months after negotiating some changes that narrowed its potential impact.

Erin Egan, Facebook’s vice president of U.S. policy, applauded the bill’s passage, saying in a statement that it would help make the internet safer “for vulnerable children, women, and all trafficking targets.”

Under the bill, victims would be required to show that a website knowingly facilitated sex trafficking in order to file a successful lawsuit.

Senator Ron Wyden, a Democrat, and Senator Rand Paul, a Republican, cast the only votes against the bill.

Wyden said the bill would lead to an onslaught of lawsuits against small websites that lack the resources to closely police user-generated content or defend themselves in court, and said it would actually benefit large internet companies.

“People following this debate might ask why some of the biggest internet companies like Facebook support it,” Wyden said. “It’s because it will pull up the ladder in the tech world, leaving the established giants alone at the top.”