WASHINGTON — The Supreme Court on Thursday refused to find that political partisanship was so extreme in drawing the maps for congressional districts in two states that it violated the Constitution. The result was a setback for advocates of political reform.

In separate votes, the court rejected claims that partisan politics played too great a role in the way congressional districts were designed in North Carolina to the benefit of Republicans and in Maryland to the advantage of Democrats.

On a 5-4 vote in the North Carolina case, the justices found that the "partisan gerrymandering claims present political questions beyond the reach of the federal courts." Chief Justice John Roberts wrote in his majority opinion that states and Congress could pass laws to prevent politically oriented districts, but asking the courts to do so would be "an unprecedented expansion of judicial power."

Dissenting justices, all on the court's liberal wing, said the high court was abdicating its responsibility to settle a deeply divisive constitutional issue. "For the first time ever, this Court refuses to remedy a constitutional violation because it thinks the task beyond judicial capabilities," Justice Elena Kagan wrote in her dissent.

A finding that excessively partisan gerrymandering violated the Constitution could have had a profound impact on American politics by making congressional and state legislative elections more competitive.

The Supreme Court has turned away such challenges in the past, concluding that because redistricting is essentially a political act, it would be impossible to determine when partisan gerrymandering crossed a constitutional line. The court seemed on the verge of finding that point two years ago. But the retirement of Justice Anthony Kennedy, who signaled that he was receptive to the claims, dimmed the hopes of reform advocates.

Advocates of political change considered the case from North Carolina to be so extreme that the court could not avoid striking down the congressional redistricting plan. After the 2010 census, the state Legislature drew a map that was intended to maintain the partisan breakdown of its congressional delegation — 10 Republicans and three Democrats.

A Republican state legislator involved in the process, Rep. David Lewis, said, "I think electing Republicans is better than electing Democrats," adding that he drew the map "to help foster what I think is better for the country."

The court also heard a challenge to the redrawing of Maryland's 6th Congressional District in 2011, which allowed Democrats to take over a seat in the U.S. House that Republican Roscoe Bartlett held for two decades. The governor at the time, Martin O'Malley, said the intent was to create a district "where the people would be more likely to elect a Democrat than a Republican."

In past cases, the court found it impossible to formulate a legal test for determining when too much partisanship was at work. The challengers in the North Carolina case contended that the constitutional line is crossed when the political party controlling the process targets the other party's voters by spreading them out among districts where they cannot form a majority, and jamming the remaining ones together to minimize the number of districts they can win.

But Republican legislators in North Carolina said gerrymandering is an issue for the political branches, not for judges.

"The time has come for this court to make clear that the Constitution does not provide courts with the tools or the responsibility to say how much partisan motivation is too much," they said in their court filings.

Thursday's decisions cast a shadow over lower court rulings that invalidated congressional district maps drawn by Republican-controlled Legislatures in Ohio and Michigan. Michigan's state legislative districts were also struck down. In both cases, the lower courts said the new maps were unconstitutional partisan gerrymanders. The Supreme Court put a hold on both those rulings while it considered the North Carolina and Maryland disputes.

The justices will probably send both of the Midwestern cases back to the lower courts for a reassessment in light of Thursday's ruling.