WASHINGTON (Reuters) - U.S. Supreme Court justices on Monday struggled over how to determine when states have unlawfully considered race in drawing legislative districts as they weighed cases in which Republicans in Virginia and North Carolina were accused of trying to dilute the clout of black voters. Based on two hours of oral arguments in the cases before the eight justices, it appeared that the voters who challenged Virginia’s plan may win but the North Carolina case’s outcome was less clear. Conservative Justice Anthony Kennedy, who sided with the court’s liberals in a ruling last year involving Alabama legislative districts, could again be pivotal. Race can be considered in redrawing boundaries of voting districts only in certain instances, such as when states are seeking to comply with the federal Voting Rights Act. That law protects minority voters and was enacted to address a history of racial discrimination in voting, especially in southern states. In both cases before the justices, voters accused Republicans of packing black voters, who tend to back Democratic candidates, into certain districts to diminish their voting power and make surrounding districts more white and more likely to support Republicans. In 2015, the Supreme Court ruled 5-4 to throw out a lower court’s decision upholding a Republican-backed state legislature redistricting plan in Alabama that crammed black voters into certain districts in a way critics claimed lessened their influence at the polls. The Supreme Court has never said redistricting cannot be based on nakedly partisan aims like maximizing one party’s election chances. Justice Stephen Breyer, who wrote the ruling in the Alabama case, acknowledged the difficulties in assessing when race has been taken into account appropriately in drawing voting districts. “No one, I think, has a good answer to that question. There is just slightly better, slightly worse,” Breyer said. Fellow liberal Justice Sonia Sotomayor said that “it’s real easy” for states to say mere politics motivated their decisions “even though there’s a lot of direct evidence that it really was race.” Conservative justices, often skeptical about considering  race in any context, expressed sympathy for the problems states face in trying to avoid lawsuits while also complying with the voting law. “Maybe there’s no way around it, but isn’t this just an invitation for litigation in every one of these instances?”  Justice Samuel Alito asked. North Carolina appealed a February federal court ruling  that found that Republicans who redrew U.S. House of Representatives districts after the 2010 census took race too much into consideration. Virginia voters who challenged the way 12 state House of Delegates boundaries were drawn by Republicans after the 2010 census appealed an October 2015 federal district court ruling upholding the districts. Rulings in both cases are due by the end of June. 