AT&T Inc., Verizon Communications Inc. and 10 other large phone companies have struck an agreement with 51 attorneys general to enact technology to block robocalls before they reach consumers.

The deal, announced Thursday, will help protect consumers from receiving illegal robocalls, and assist law enforcement in investigating and prosecuting bad actors, said North Carolina Attorney General Josh Stein, who is leading the effort that includes all 50 states and the District of Columbia.

Under the deal, the companies will launch the call-blocking technology at no cost to consumers, and make other free anti-robocall devices and apps available to subscribers.