North Carolina Gov. Pat McCrory speaks to supporters at an election rally on Nov. 9 in Raleigh, N.C. (Chuck Burton/AP)

Sometime after Barack Obama’s surprise win in 2008 and the tea party’s revenge two years later, what once passed for genteel politics in North Carolina began to more closely resemble hand-to-hand combat.

At times, it’s hard to know which side is winning.

Last month, Donald Trump prevailed over Hillary Clinton here. But Democrats won other key races. The Republican governor, Pat McCrory, is probably on his way out — though he has faint hopes for a contentious recount — and the Democratic candidate for the state Supreme Court won a surprise victory, teeing up what could be a nasty partisan battle over the composition of the state’s highest court.

Even the laws under which North Carolina conducts its elections are contested.

Just months before the November balloting, federal judges rejected major new voting restrictions as racially motivated and unconstitutional. Other federal judges have separately blown the whistle on gerrymandering of state legislative districts intended to cement the Republican Party’s dominant role.

The battle over North Carolina continues Monday in the U.S. Supreme Court, when the justices will hear yet another election case, considering whether the drawing of the state’s congressional districts was also unconstitutionally influenced by race.

It will not be the first time the court has reviewed the state’s reapportionment decisions; it will be the fourth.

“North Carolina . . . might as well have a wing on the United States Supreme Court dedicated to redistricting,” said Dallas Woodhouse, the executive director of the state Republican Party.

North Carolina displays many of the same dynamics that produced such a divisive election nationwide last month.

“They’ve called it the great sorting, as Democrats move to big cities and the Republicans either stay or move to rural settings,” said Kevin J. Hamilton, a lawyer representing Democratic Attorney General Roy Cooper, who has declared victory in the gubernatorial race. “I think we see that in North Carolina as well; it’s a very equally divided state. And North Carolina’s not alone — there are a number of states like that.”

David McLennan, a political scientist at Meredith College, agreed.

“I think North Carolina almost is a 50-50 state,” he said, adding, “There is no will for compromise.”

That is partly because one political party remains overwhelmingly in charge.

If Obama’s 2008 victory “shook the state to its core,” in the words of Catawba College Provost J. Michael Bitzer, a Republican landslide in 2010 had a more lasting effect.

Under congressional districts drawn by the Republican legislature after that vote, the GOP has captured 10 of 13 seats. There are Republican supermajorities in both chambers of the General Assembly.

And Republicans control the State Board of Elections, which proved useful last week. On a ­party-line vote, members ordered a recount of about 90,000 ballots in the governor’s race from the Democratic stronghold of Durham County, where machine problems delayed counting the ballots.

They all came at once, late on election night. “In the blink of an eye,” Republican board member James Baker said, McCrory went from a 50,000-vote lead to a deficit. (As of Friday, unofficial state totals showed Cooper with a 10,263-vote lead.)

Board members, who had been inundated with calls organized by the Republican Party demanding a recount, acknowledged that it might not change anything but said the exercise would remove a “taint” from the results.

In a state where the center once controlled, Republicans have pressed a highly partisan agenda since taking charge. GOP leaders passed one of the nation’s most restrictive voting laws, with ID requirements and a reduction in early voting. And the legislature passed HB 2, the “bathroom bill” that says people must use restrooms in government buildings and public schools that correspond to the gender on their birth certificate, and nullifies local efforts to extend additional rights to gay and transgender people.

“North Carolina has become a purple state,” said Allison Riggs, a lawyer with the Southern Center for Social Justice. “But Republicans insist on acting as if it is still a red state.”

Most believe that HB 2 cost McCrory. Businesses have said they are not coming to the state or expanding because of the law. And North Carolina’s sports-crazed citizens saw the NBA cancel plans to hold its All-Star Game in Charlotte, and the NCAA and Atlantic Coast Conference vow not to hold tournaments or championship games in the state.

Bitzer noted that when McCrory, a former Charlotte mayor, won four years ago, he carried Mecklenburg County, which includes the city, by a few thousand votes. In his reelection bid, he lost it by about 137,000.

Woodhouse acknowledged that HB 2 hurt McCrory in urban areas, but he said the bill probably helped him elsewhere.

McLennan agreed: “If you drive 30 miles out from Raleigh, you’re in a very different place.”

Whatever happens in North Carolina is seen through a “partisan lens,” Bitzer said. “Democrats would argue that Republicans went too far. Republicans say the federal courts are intervening when they shouldn’t.”

The Charlotte Observer recently reported that the Republican leadership has spent $10.5 million in outside legal fees defending its laws, mostly in losing efforts.

The U.S. Court of Appeals for the 4th Circuit struck down the voting changes law, saying the legislature enacted the new restrictions intentionally to blunt the growing clout of African American voters.

“The new provisions target African Americans with almost surgical precision” and “impose cures for problems that did not exist,” Judge Diana Gribbon Motz wrote for the panel.

Last week, a different panel of federal judges said new districts must be drawn for 28 state legislative seats in the coming months and special elections held in 2017.

“While special elections have costs, those costs pale in comparison to the injury caused by allowing citizens to continue to be represented by legislators elected pursuant to a racial gerrymander,” the judges wrote.

Woodhouse said it was absurd for the court to order new elections just weeks after voters went to the polls. Democrats “are never going to have a majority as long as we draw the maps,” he said. “So their goal is to have courts draw them.”

Racial gerrymandering is also at the heart of the case the Supreme Court will hear Monday. Yet another panel of federal judges found that GOP mapmakers packed African American voters into two congressional districts, which limited their influence in other districts.

In a briefing filed at the Supreme Court, lawyers for the state point out that it was Democrats who first drew those majority-minority districts decades ago, in order to ensure that black voters could elect representatives of their choice.

These lawyers note that the state Supreme Court heard the same challenge to the current congressional plan and concluded that the legislature’s action complied both with the equal-protection guarantee of the 14th Amendment and with the Voting Rights Act.

The federal courts should never have gotten involved, wrote former George W. Bush administration solicitor general Paul D. Clement, who is representing North Carolina in the matter.

The brief candidly says the state’s maps were motivated by politics. While racial gerrymandering is constitutionally forbidden, the Supreme Court has never found the same of partisan gerrymandering.

Woodhouse said it is the prerogative of the ruling party to protect the gains it has made, just Democrats did when they controlled the legislature.

“Democrats play politics, too,” he said. “I know that’s a shock.”