North Carolina’s legislative and congressional boundaries were upheld Monday by a three-judge panel, a victory for Republicans who drew the maps and a blow to Democrats and allies who challenged them.

The Superior Court judges, in a unanimous 171-page decision, rejected the arguments of Democratic voters, civil rights groups and election advocates who sued 20 months ago over the lines and argued they were racial gerrymanders.

“It is the ultimate holding of this trial court that the redistricting plans enacted by the General Assembly in 2011 must be upheld and that the enacted plans do not impair the constitutional rights of the citizens of North Carolina as those rights are defined by law,” the ruling said.

The decision, which is likely to be appealed to the state Supreme Court, reaffirms the lines intended for use through the 2020 elections and already have been shown to favor Republicans. During the 2012 elections, the GOP padded their majorities in the House and Senate and won nine of the state’s 13 U.S. House seats, compared to six before.

In South Carolina, former Democratic Party chair Dick Harpootlian filed a court challenge to the redistricting but also lost in court.

However, Harpootlian said recently he is looking at reviving that challenge — either by asking the court to reconsider or by filing a new lawsuit — in the wake of the U.S. Supreme Court’s decision to overturn part of the Voting Rights Act.

Harpootlian argued Republicans gerrymandered both state and congressional districts to pack them with as many Democrats as possible, which also made for many more safe Republican seats.

The Voting Rights Act required both North and South Carolina to “preclear” their 2011 maps with U.S. Justice Department attorneys or a federal court. A U.S. Supreme Court ruling two weeks ago essentially ends the requirement moving ahead unless Congress acts.

In North Carolina, Democrats have been reeling after poor showings in the last two election cycles. Republicans now control the legislative and executive branches for the first time in 140 years. Successful 2010 elections gave Republicans the power to draw the maps based on the once-a-decade census figures.

The ruling pointed out that each judge “independently and collectively arrived at the conclusions” set out in the decision, despite their “differing ideological and political outlooks.” The judges — Paul Ridgeway of Wake County, Alma Hinton of Halifax County and Joseph Crosswhite of Iredell County — were appointed by Chief Justice Sarah Parker to hear the case.

The lawsuits were first filed in November 2011. They heard four days of oral arguments this year, including two days last month.

The lawsuits argued the maps were unlawful because they needlessly created legislative districts in which black residents are a majority of the voting-age population. They said the GOP illegally packed black voters into sprawling districts, split voting precincts and failed to keep whole counties within districts.

Attorneys representing the state and legislative leaders disagreed, saying the maps were fair and in line with previous federal and state redistricting decisions. 2011 Redistricting Committee chiefs Sen. Bob Rucho, R-Mecklenburg, and Rep. David Lewis, R-Harnett, said the ruling is “clear repudiation” of the arguments in the lawsuits.

“This unanimous decision should put to rest the baseless arguments that the General Assembly engaged in racial discrimination during the redistricting process,” they said in a news release.

Those who challenged the maps sounded poised to appeal Monday. “There are numerous issues that will need to be resolved by higher courts,” according to a news release attributed to the dozens of Democratic voters who filed one of the lawsuits.

The Rev. William Barber, president of the North Carolina chapter for the National Association for the Advancement of Colored People, which also sued, said the judges didn’t disagree with the facts they presented.

“It’s a disagreement of interpretation of law,” Barber said.

In particular, the mapmakers said creating black-majority districts in some areas of the state were a lawful way to prevent the state from subjecting itself to legal claims under the federal Voting Rights Act, designed to protect minority voters.

In the ruling, the judges wrote several times that the General Assembly “had a strong basis in evidence,” including other court cases, hearing testimony, previous election results and map and census data, to draw the maps the way they did.

The plaintiffs challenged 30 districts — nine in the state Senate, 18 in the state House and three for Congress. They complained that Republicans created many majority-minority districts in regions where black voters had elected their favored candidates in coalitions with whites for decades to diminish their voting power.

Those who sued also contended that race was the predominant factor — and an illegal racial gerrymander if true — in forming four districts not subject to the Voting Rights Act. But the judges wrote that evidence showed the maps were drawn with many factors in mind, making them “more competitive for Republican candidates.”

Attorneys challenging the maps said the Republicans’ gerrymandering resulted in strange-looking districts that confused voters. But the judges said they couldn’t discern any meaningful difference between the shape of districts and alternatives offered by critics, and any decision would be subjective.

“To be sure, there are several districts in the enacted plan that are ‘ugly’ and that would appear to most to be bizarrely shaped, irregular and non-compact,” the judges said, but they couldn’t “find that any district, simply on this ground alone, can be declared to be in violation of law or unconstitutional.”

South Carolina’s new districts also have been criticized by some for being bizarrely shaped and confusing to voters.

During the recent 1st Congressional District race, where Republican Mark Sanford beat Democrat Elizabeth Colbert Busch, many voters had difficulty learning whether they were eligible to vote in the newly-drawn district.

Only a search of the state’s voter registration database could determine the answer, as the 1st and 6th districts cut through dozens of neighborhoods.

At Charleston’s Sanders Clyde Elementary polling place, more ineligible voters showed up to cast ballots than eligible ones.

The Post and Courier’s Robert Behre contributed to this report.