ATLANTA — North Carolina’s Republican-controlled legislature and its Democratic governor announced late Wednesday that they had reached an agreement to repeal the controversial state law that curbs legal protections for lesbian, gay, bisexual and transgender people and sets rules that affect transgender bathroom use in public buildings.

But gay rights advocates raised objections, arguing that the compromise would continue to allow discrimination. And it was unclear late Wednesday whether the deal, if approved, would end the boycotts by sports leagues, businesses and others that have harmed the state’s reputation and economy.

The law in question, often referred to as House Bill 2, was signed in March 2016 by the state’s governor at the time, Pat McCrory, a Republican. One of the most contentious measures requires transgender people in public buildings to use the bathroom that corresponds with the gender on their birth certificate.

Phil Berger, the Senate leader, and Tim Moore, the House speaker, announced late Wednesday that they had reached the agreement with the new Democratic governor, Roy Cooper. A bill repealing House Bill 2, which the legislature will consider on Thursday, would also create a moratorium on local nondiscrimination ordinances through 2020 and leave regulation of “multi-occupancy facilities,” or bathrooms, to state lawmakers.