ATLANTA — The North Carolina Senate voted in favor of a bill Thursday that repealed the controversial law affecting transgender bathroom use in public buildings, part of a compromise worked out earlier in the week between Republican legislative leaders and the Democratic governor.

But with anger rising over the compromise from groups on both the left and right, it was unclear whether eventual passage of the new bill into law would extricate North Carolina from the roiling national controversy over the proper levels of legal protections for lesbian, gay, bisexual and transgender people.

The bill passed the Senate, 32-16, in a late morning vote after only brief discussion. The Senate Democratic leader, Dan Blue, said that while the state still needed to have a conversation about making sure “everybody’s dignity is respected,” something needed to be done to end the boycotts sparked by the existing law, known as House Bill 2.

The compromise, he said, “brings an end to an economic threat.”

Phil Berger, a Republican and the Senate leader, acknowledged that many people were likely not pleased by the compromise. However, he said, “compromise sometimes is difficult, and this bill represents that.”

The bill now goes to the state House for a vote. It will then require the signature of Gov. Roy Cooper, a Democrat, who said Wednesday that he supported it.

House Bill 2 was signed in March 2016 by the state’s governor at the time, Pat McCrory, a Republican. It curbs legal protections for lesbian, gay bisexual and transgender people and, in perhaps its most contentious measure, requires transgender people in public buildings to use the bathroom that corresponds with the gender on their birth certificate.

The new bill repeals House Bill 2, creates a moratorium on local nondiscrimination ordinances through 2020 and leaves regulation of bathrooms to state lawmakers.

In a brief statement Wednesday, Mr. Cooper — whose razor-thin victory over Mr. McCrory in November was due in large part to voter frustration over the national backlash over House Bill 2 — said that the new bill was “not a perfect deal, but it repeals House Bill 2 and begins to repair our reputation.”

Gay rights advocates have been harshly critical of the proposed compromise. Cathryn Oakley, senior legislative counsel for the Human Rights Campaign, said that it would leave lesbian, gay, bisexual and transgender people with no statewide anti-discrimination ordinance and no ability to seek such protections from local government for a number of years.

“What that means for the L.G.B.T. community is that we continue to be boxed out of nondiscrimination protections,” she said.

Chris Sgro, executive director of the gay rights group Equality North Carolina, said that the proposal “keeps North Carolina as the only state in the country obsessed with where trans people use the restroom through law.”

The conservative NC Values Coalition, meanwhile, was urging its followers to contact lawmakers and tell them not to repeal House Bill 2, arguing that the existing law guarantees that men won’t be allowed “into women’s and little girl’s bathrooms and showers.”

“No NCAA basketball game, corporation, or entertainment concert is worth even one little girl being harmed or frightened in a bathroom,” Tami Fitzgerald, executive director, wrote in an email. “She should not lose her privacy and dignity to a boy in a locker room.”

The announcement of a compromise on Wednesday came after months of acrimony over the bill and a seeming inability to find middle ground after numerous efforts. Conservative legislators, citing safety concerns, have been worried about the idea of men using women’s restrooms since the Charlotte city government, in February 2016, passed an ordinance that allowed transgender people to use the restroom of their choice. Charlotte officials repealed that ordinance in December as part of one of the efforts to broker a compromise in the state capital, but that effort failed dramatically during a special legislative session.

This week, a new flurry of action over House Bill 2 came as the N.C.A.A. warned the state that it could lose the opportunity to host championship sporting events through 2022. The league had already relocated championship tournament games that would have been played in North Carolina during this academic year, including the Division I men’s basketball tournament.

The possibility of further punishment placed tremendous pressure on lawmakers in the basketball-obsessed state, a pressure exacerbated by the fact that the University of North Carolina men’s basketball team has reached the N.C.A.A. tournament’s Final Four and will be squaring off against the University of Oregon on Saturday night.

The Atlantic Coast Conference also moved its neutral-site championships out of North Carolina this year in response to House Bill 2, and the National Basketball Association moved its All-Star game to New Orleans from Charlotte.

Some local news outlets reported this week the N.C.A.A. had set a Thursday deadline for the state to address the bill. Officials at the association could not be reached for comment Wednesday. A league statement last week stated, “Absent any change in the law, our position remains the same regarding hosting current or future events in the state.”

The Associated Press released an analysis this week that estimated that House Bill 2 would cost North Carolina more than $3.7 billion in lost business in the next 12 years.