Opponents of political gerrymandering had reason for optimism at the Supreme Court on Tuesday, with Justice Anthony M. Kennedy, the likely swing vote, appearing more in sync with liberal colleagues who seemed convinced that a legislative map can be so infected with political bias that it violates the Constitution.

But it’s what Kennedy didn’t say that could determine whether the court, for the first time, strikes down a legislative map because of extreme partisan gerrymandering. While he has previously expressed concerns about the political mapmaking practice, he has yet to endorse a way of determining when gerrymandering is excessive, and Kennedy give no sign at oral arguments Tuesday that he had found one.

In a case from Wisconsin that could reshape the way American elections are conducted, the Supreme Court heard from challengers that it was the “only institution in the United States” that could prevent a coming wave of extreme partisan gerrymandering that would distort the basic structure of democracy.

“Politicians are never going to fix gerrymandering,” said Paul M. Smith, representing Democratic voters who challenged a 2011 redistricting plan drawn by Wisconsin’s ruling Republicans. “They like gerrymandering.”

Even conservative justices skeptical of Smith’s argument seemed to agree that it was unsavory for members of the party in power to draw legislative districts to protect themselves and their own, and make it hard for opponents to ever gain power.

“Gerrymandering is distasteful,” said Justice Samuel A. Alito Jr. “But if we are going to impose a standard on the courts, it has to be something that’s manageable.”

Finding a test that courts could use to determine when political favoritism had become too great — the “Rosetta Stone,” Alito called it — has always been the hurdle. Kennedy said as much the last time the court examined the issue, in 2004.

If anything, Kennedy seemed more convinced this time around that the courts have a role in finding that partisan gerrymandering can be so extreme as to be unconstitutional.

He pressed lawyers for the state and its legislative leaders about whether it would be unconstitutional for a state to undertake the redistricting process by forthrightly saying it intended to favor one party over another.

Erin Murphy, representing the legislative leaders, hesitated and said that was not the case in Wisconsin.

Kennedy was undeterred. “I’d like the answer to the question,” he said.

Murphy and the state’s lawyer, Solicitor General Misha Tseytlin, agreed that would be unconstitutional.

Kennedy did not ask any questions of Smith. And the tone of the oral arguments indicated Kennedy seemed to be agreeing more with liberal justices who felt courts must police gerrymandering than conservative justices who were wary of getting involved.

But he also stopped short of indicating that he believed Wisconsin’s plan was so flawed it should be overturned, or that the challengers had come up with the elusive tests he had said were necessary in his 2004 opinion.

A panel of three federal judges ruled 2 to 1 that Wisconsin’s leaders went too far in using a secretive process for drawing the maps after the 2010 Census.

The lower court concluded that the districting plans were drawn to eliminate swing districts and create ones favorable to Republicans. That court found that the shape of the districts could not be explained by nonpartisan reasons and that the advantage given to Republicans would be “enduring” through the decade even if Democrats outperformed Republicans at the polls.

The judges said Republicans packed Democrats into some districts and spread them out across others as a way to create more districts conducive to a GOP candidate.

The plans, developed in 2011 by Republican leaders who controlled the legislature and signed by Gov. Scott Walker (R), were effective.

In the election held after the new district maps were adopted, Republican candidates won 48.6 percent of the statewide vote but captured a 60-to-39 seat advantage in the State Assembly.

If the Supreme Court doesn’t rule that such a plan is unconstitutional, Smith told the court, “in 2020, you’re going to have a festival of copycat gerrymandering the likes of which this country has never seen.” States are required to redraw legislative and congressional districts after every decade’s census.

Chief Justice John G. Roberts Jr. pushed back. He said Smith was asking the courts to effectively take over the process of redistricting from elected officials. He said the tests to gauge gerrymandering offered by the challengers were based on mathematical tests and political-science theories, which he characterized as “sociological gobbledygook.”

Every redistricting plan will be contested, Roberts said. “We will have to decide in every case whether the Democrats win or the Republicans win.”

The court can attempt to explain the complicated tests used in making such a determination, he said, but “the intelligent man on the street is going to say that’s a bunch of baloney.”

But liberal Justice Stephen G. Breyer did not think the court’s task would be so hard.

For one thing, only maps produced in states where one party controlled the process could be accused of excessive partisanship, he said.

He suggested the test could be as simple as this: If one party wins only a minority of the statewide vote but still gains a majority of legislative seats, does the same possibility exist for the other party?

The plans developed by Wisconsin Republicans showed that they could hang on to the majority of seats with less than 50 percent of the statewide vote, but that Democrats would need more than 53 percent of the vote to win a majority.

When Alito and Justice Neil M. Gorsuch worried about courts having to apply conjecture to evaluate a state’s plan, Justice Elena Kagan said the expanding world of technology had made it routine to create maps and evaluate their performance.

“I was under the impression that legislators are capable of doing this actually pretty easily now,” she said.

Justice Sonia Sotomayor noted that the Wisconsin mapmakers drew and rejected maps until they came up with one that maximized Republican chances, and then it succeeded beyond their expectations.

She and Justice Ruth Bader Ginsburg also asked more-fundamental questions.

“Could you tell me what the value is to democracy from political gerrymandering?” Sotomayor asked Murphy.

Murphy said that even Breyer had noted in a previous case that such districting gives constituents a way to know the legislature and whom to hold accountable. “It produces values in terms of accountability that are valuable so that the people understand who isn’t and who is in power,” Murphy replied.

Sotomayor countered: “I really don’t understand” how that makes it “okay to stack the decks.”

Ginsburg, too, had the big picture in mind.

“If you can stack a legislature in this way, what incentive is there for a voter to exercise his vote?” Ginsburg asked. “Whether it’s a Democratic district or a Republican district . . . the result is preordained in most of the districts.”

She added: “What becomes of the precious right to vote?”

The case is Gill v. Whitford.