Back in March, the Republican-controlled North Carolina legislature passed and Gov. Pat McCrory signed into law the controversial House Bill 2, which requires people to use public bathrooms that match the gender on their birth certificate, removes sexual orientation from the state's nondiscrimination policy and bars local governments from raising the minimum wage above the state's.

The so-called "bathroom bill" sparked fierce opposition from human rights advocates and an economic boycott, with companies, film productions and high-profile sporting events pulling out of the state in protest of the discriminatory law. HB2's economic toll was estimated at up to $700 million at the time of the November election, and an ABC News exit poll found 66 percent of North Carolina voters opposed it.

In six state contests, HB2 appears to have played a role in the outcome, as champions of the law either lost or are trailing their opponents in still-unsettled races.

Governor

In a state that Republican President-elect Donald Trump won by 4 percentage points and incumbent GOP U.S. Sen. Richard Burr won by 6 points, McCrory is trailing his Democratic challenger, Attorney General Roy Cooper, by about 5,000 votes, with more ballots to be counted and McCrory challenging votes in 52 of North Carolina's 100 counties.

Cooper refused to defend HB2 in court, calling it "discrimination" and a "national embarrassment" and saying that "it will set North Carolina's economy back." He campaigned against HB2 and received support from LGBT advocacy groups.

Outside groups unaffiliated with campaigns spent heavily on the governors race, which drew at least $14.7 million in outside spending, shattering the 2012 total of $8.1 million. Some outside groups backed Cooper because of his anti-HB2 stance, while others supported McCrory for signing and defending the law.

The pro-LGBT Human Rights Campaign's PAC joined with state-based Equality North Carolina's Action Fund PAC in an initiative called TurnOUT N.C., which mobilized voters to cast ballots for HRC- and Equality N.C.-endorsed candidates, including Cooper. HRC has reported spending over $1 million on a TV ad, online ads including some benefiting Cooper, telephone calls and staff time. While the reports do not indicate who some of the expenditures targeted, it's clear that much of the money spent by HRC supported Cooper.

The N.C. Values Coalition and its affiliated independent expenditure PAC together spent nearly $550,000 on TV and digital ads attacking Cooper for his opposition to HB2. Funding those ads were a mysterious new Chapel Hill-based limited liability corporation called Ad Valorem; the political spending arm of the Washington, D.C.-based Family Research Council, which the Southern Policy Law Center considers an anti-LGBT hate group; the Colorado-based Family Policy Alliance, an ally of the Family Research Council with a North Carolina branch that advocated for HB2's passage; and the National Organization for Marriage, which opposes same-sex marriage and transgender rights. The Family Policy Alliance also spent over $23,000 on "Vote Your Values" mailers backing McCrory.

Attorney general

The race to replace Cooper as state attorney general pitted Democrat Josh Stein, a former state senator, against current Republican state Sen. Buck Newton. As chair of the Senate Judiciary Committee, Newton served as the sponsor of HB2 when it moved through his chamber and has been an outspoken defender of the law.

Stein often brought up Newton's support for HB2 while campaigning and released an ad calling Newton "the cheerleader for HB2." Stein leads Newton by over 20,000 votes, but Newton has not yet conceded. While the race drew at least $4.2 million in outside spending, it's unclear if any of it referenced HB2. Stein also benefited from the pro-LGBT TurnOUT N.C. campaign.

State legislature

A liberal, state-based outside spending group, N.C. Families First, sent hundreds of thousands of dollars' worth of mailers attacking Republican state House members for supporting HB2. In two liberal-leaning urban counties, Wake and Mecklenburg, the efforts appear to have worked.

In Wake County, home to the state capital of Raleigh, Families First targeted incumbent state Reps. Gary Pendleton and Marilyn Avila. In Mecklenburg County, home of Charlotte, the group took aim at incumbent state Rep. Rob Bryan and Beth Danae Caulfield, who ran for the open District 92 seat against Democrat Chaz Beasley. Pendleton, Bryan and Caulfield all lost close races, while Avila, an HB2 sponsor, trails her challenger by about 400 votes in a race that has still not been called.

Legislative candidates and the state Democratic Party used the same tactic as the outside spending group. Democrat Mary Belk, who unseated Bryan, produced an ad associating her opponent with McCrory and the hundreds of millions of dollars in economic losses for Mecklenburg County because of HB2.

Meanwhile, the Democratic Party sponsored an ad criticizing Wake County state Sens. Tamara Barringer and Chad Barefoot for "helping McCrory pass HB2." Barefoot kept his seat, while Barringer is hanging on by 1 point and has not yet officially been declared the winner.