As House, Senate panels separately weigh solutions, Internet sites are fearful of losing the broad immunity granted to online businesses under federal law

WASHINGTON—A dispute over how to deter a flourishing online sex trade is likely to escalate into a high-profile policy battle in 2018, adding to political headaches for big tech.

Lawmakers for months have been working on ways to address the issue, which has its roots in a 1990s law that gives websites and other online businesses broad legal immunity for activity of their users. The law has provided legal cover for adult classified-ad sites such as Backpage.com to develop into big businesses, shielding them from lawsuits by...