RALEIGH, N.C. — Roy Cooper, a Democrat, held a razor-thin lead on Thursday in North Carolina’s bitterly contested race for governor. If it holds, it would be a rare bright spot for his party this week, one that has much to do with Mr. Cooper’s call for repealing a state law limiting transgender bathroom access that has subjected North Carolina to a gale of international criticism, boycotts and cancellations.

Yet many here are now predicting that the contentious law, which catalyzed a national debate over lesbian, gay, bisexual and transgender rights, is unlikely to be repealed even if Mr. Cooper becomes governor.

On Thursday, State Representative Rodney W. Moore was one of a number of Democratic lawmakers who predicted that Republicans here in the capitol would have little reason to dump the law, commonly known as House Bill 2, or H.B. 2, even if Mr. Cooper were elected.

Gov. Pat McCrory, a Republican seeking his second term, has refused to concede until thousands of mail-in and provisional ballots are counted by elections boards in each of the state’s 100 counties. That process is set to conclude on Nov. 18. Mr. McCrory was widely criticized for having signed the law.