The four major U.S. wireless carriers--Verizon Communications Inc., AT&T Inc., T-Mobile US Inc. and Sprint Corp. pledged to stop selling the locations of individual customers to two middlemen amid accusations that one of the firms mishandled the information.

The carriers said they will wind down data-sharing agreements with LocationSmart and Zumigo Inc., which buy access to the real-time locations of users from major U.S. carriers and allow other businesses to tap into it. The data are used for everything from marketing nearby...