At a LinkedIn town hall meeting in 2011, President Barack Obama was gushing in his praise of Silicon Valley. "No part of the country better represents the essence of America than here," he reportedly told industry chiefs gathered in the Computer History Museum in Mountain View, California, lauding the tech industry's record of entrepreneurship.

In recent months, the relationship between lawmakers and the Silicon Valley has soured.

Senators and tech giants are at loggerheads over a new bill that would make it easier for lawmakers to go after websites that host sex trafficking ads.

The bill emerged from Senate investigations into the website Backpage.com, which was accused of running ads facilitating child sexual exploitation and sex trafficking. The website shut down its adult services page in January, claiming "unconstitutional government censorship" as it did so.

At a Senate hearing Tuesday, a tearful Yvonne Ambrose, whose 16-year-old daughter was found beaten and stabbed to death outside Chicago, a victim of online sex trafficking, said, "It could be your child." Ambrose said the site "must be held accountable."

The bill would do that by changing Section 230 of the Communications Decency Act, which currently protects websites from litigation over content posted by users.

Google, Facebook and tech industry trade groups oppose the bill, and have deployed their substantial lobbying resources against a measure they claim would devastate their business model. They claim the bill would make it easier for them to be sued for content posted by third parties.

Lawmakers are also locked in a separate dispute with Facebook after a Russian group tied to the Kremlin bought up political advertisements on its site during the 2016 presidential election.

Senator Mark Warner, the top Democrat on the Senate Intelligence Committee, has called for the company to be more forthcoming about its advertising clients, while Representative Adam Schiff, the lead Democrat on the House intelligence committee, told MSNBC that the company was reluctant to disclose information because "it's against their economic interest to be advertising problems about how a foreign government was exploiting their technologies."

Facebook has not commented on the allegations, apart from confirming that the Kremlin-linked Internet Research Group spent $100,000 buying ads on the social media platform in 2016.

Experts have predicted the battle between technology companies and politicians will be protracted, as the lawmakers struggle to keep up with the pace of technological change.

"Technology is moving faster than our ability to understand it, and there is no consensus on what is ethical. It isn't just the lawmakers who are not well-informed, the originators of the technologies themselves don't understand the full ramifications of what they are creating," wrote tech entrepreneur Vivek Wadhwa in The Washington Post last year.

"It takes decades, sometimes centuries, to reach the type of consensus that is needed to enact the far-reaching legislation that Congress will have to consider."