A divided Supreme Court on Wednesday said a lower court must take another look at whether Alabama's Republican-led legislature relied too heavily on race when it redrew the state's voting districts in a way that black leaders say limited minority voting power. 

The justices split 5-4 across ideological lines in ruling that a three-judge panel did not properly consider complaints that state officials illegally packed black voters into too few voting districts. 

Writing for the court, Justice Stephen Breyer said the lower court should have reviewed claims of racial gerrymandering on a district-by-district level, not just statewide. He also said the court didn't apply the right test when it found that race wasn't the primary motivating factor. 

Breyer said both the district court and the state legislature relied too much on a "mechanically numerical" view of whether the new plan reduced minority voting strength. Instead of asking how it could maintain the minority percentages in districts, the court should have asked what percentages the minority should have to elect their candidate of choice. 

"Asking the wrong question may well have led to the wrong answer," Breyer said. 

Justice Anthony Kennedy, often a swing vote, joined the court's four liberals in the majority. 

State officials say they had no choice but to concentrate black voters in some districts, making neighboring seats more white and apt to elect Republicans. 

African-Americans challenging the state's Republican-drawn maps said black voters should have been somewhat dispersed to increase their influence in elections. 

A panel of three federal judges had ruled 2-1 in 2013 that the new districts were not discriminatory and did not violate the Voting Rights Act or the Constitution. 

Like other states, the Alabama Legislature had to redraw political boundaries to reflect population shifts in the 2010 Census. The process can often lead to gerrymandering -- the manipulation of district boundaries to gain a partisan advantage. 

In dissent, Justice Antonin Scalia said the court's majority "issues a sweeping holding that will have profound implications for the constitutional ideal of one person, one vote, for the future of the Voting Rights Act of 1965 and for the primacy of the state in managing its own elections."