Besieged by nearly five billion unwanted automated calls from telemarketers and scammers last month, Americans are poised to get relief from robocalls under a bipartisan compromise bill introduced in the House on Thursday.

The measure would require phone carriers to offer screening technology to identify and block spam calls at no additional cost to customers within 18 months of the bill’s being enacted.

Known as the Stopping Bad Robocalls Act , the legislation was first introduced in February by Democrats, who finally reached a deal Thursday with Republicans on the bill’s language.

The revamped bill was unveiled by the chairman of the House Energy and Commerce Committee, Frank Pallone Jr., Democrat of New Jersey, and the committee’s ranking member, Greg Walden, Republican of Oregon. It would apply to both wireless phones and land lines, according to Mr. Pallone, who said he was optimistic about the bill’s chances of winning House and Senate approval and being signed by President Trump.