RALEIGH, N.C. (AP) — A decade ago, GOP leaders developed a strategy to take over North Carolina’s state government for the first time since 1870: Aggressively pursue the seats of vulnerable Democratic lawmakers and win House and Senate majorities by 2010; use those majorities to redistrict the state in Republicans’ favor; and push a business-friendly, socially conservative agenda in a Southern state where progressive policies once held sway.

The formula worked. With both houses and the governor’s office under their control, Republicans can do what they want in Raleigh.

But now, as lawmakers prepare to enter their annual legislative session Monday, the courts, and possibly the court of public opinion, are threatening to imperil the Republicans’ right-leaning agenda.

At least seven Republican-backed laws have been partially or fully overturned by state and federal courts since 2011, including three since September alone, even as millions in taxpayer funds have been spent defending them. Other laws are still being challenged in court.

And now the Republicans may face their biggest test with House Bill 2, approved during a one-day special session last month. The law limits LGBT anti-discrimination rules by state and local governments. It also says that in public schools, universities and government buildings, transgender people must use the restrooms and locker rooms of their gender at birth.

The law has drawn criticism nationwide from equality advocates, corporate executives, movie stars and musicians like rock star Bruce Springsteen, who canceled a concert in protest. Civil liberties groups and transgender plaintiffs are suing to overturn it.

A federal appeals court ruling this past week in a separate lawsuit would, if allowed to stand, prove fatal to a key portion of North Carolina’s law. It says a Virginia high school discriminated against a transgender teen by forbidding him from using the boys’ restroom.

The Virginia ruling will add to the tremendous outside pressure to repeal the law. Public protests are expected on opening day.

“We have gotten up and told them on the House floor and in private that if they proceeded with their radical agenda, it would get challenged in the courts and it would probably be overturned in the courts,” said Rep. Grier Martin of Raleigh, a Democratic party leader.

But the opposition appears only to have stiffened the GOP’s resolve.