The US supreme court appeared to be leaning toward striking down cornerstone civil rights legislation that has protected African Americans' right to vote for half a century during a combative hearing on Wednesday.

The justices clashed over whether discrimination is still an issue with one, Antonin Scalia, deriding the legislation under dispute as "perpetuation of racial entitlement". They also disagreed over whether it is for Congress or the courts to decide whether measures that discourage or diminish minority votes require federal intervention.

The case was brought by an Alabama county which argued that the state is being singled out by a provision in the 1965 Voting Rights Act, widely regarded as one of the most important pieces of US civil rights legislation, that subjects states with a history of disenfranchising black people, mostly in the south, to US Justice Department oversight of their election laws and procedures.

Bert Rein, representing Shelby County, told the court that the act has done its job in ensuring the right of African Americans to register and vote. He said it is unjust to continue to subject Alabama to a provision, known as Section 5, requiring the state to seek prior approval from the US Justice Department for changes to the conduct of its elections.

Rein said that when Congress renewed the act for 25 years in 2006 it should have taken into account the realities in Alabama at that time – not the conditions in 1965. He argued that Shelby County should be considered in comparison to the conduct of other jurisdictions across the US today and not what it has done in the past.

But Rein was quickly challenged by Justice Sonia Sotomayor who described Shelby County as having a record that is "the epitome of what caused this law in the first place".

"Assuming I accept your premise, and there's some question about that, that some portions of the south have changed. Your county pretty much hasn't," she said. "In the period we're talking about it has 240 discriminatory voting laws that were blocked by Section 5 objections."

Section 5 covers all of nine states – Alabama, Alaska, Arizona, Georgia, Louisiana, Mississippi, South Carolina, Texas and Virginia – and parts of seven others.

The justices agreed that the Voting Rights Act has caused huge progress but there was strong disagreement over whether it has achieved its aims and is still necessary.

Justice Elena Kagan argued that while the initial aim of ensuring African Americans could vote had been met, there is a "second generation" of discrimination under way with the insidious use of other devices, such as the drawing of electoral boundaries, voter identification laws and the placing of polling stations, which are intended to undermine the power of minority votes.

"Think about this state that you're representing. It's about a quarter black but Alabama has no black statewide elected officials," she said.

Kagan said that while Rein objected to the formula used by Congress to decide which states should have their elections still fall under federal oversight, "by any formula Congress could devise, Alabama would be captured".

One of the questions the justices are considering is whether it is unjust to impose controls on Shelby County and Alabama if other jurisdictions which may be similarly guilty are not also subject to the same constraints.

Sotomayor told Rein that he was trying to obscure continuing discrimination in Alabama.

"You're asking us to do something, which is to ignore your record and look at everybody else's," she said.

Rein responded that the number of black members of the Alabama legislature is proportionate to African Americans living in the state.

The argument was at times framed in terms of dealing with a disease and whether the remedy should still be applied, or whether there is a new disease requiring a different remedy.

"It's an old disease," said Justice Stephen Breyer. "It's gotten a lot better. A lot better. But it's still there."

Part of the disagreement between the justices centred on how Congress reached the decision to renew the Voting Rights Act. Sotomayor noted that Congress compiled a long record of recent measures by the affected states that discriminated against minority voters at elections.

Congress found that without the continuation of protections through the Voting Rights Act "racial and language minority citizens will be deprived of the opportunity to exercise their right to vote, or will have their votes diluted, undermining the significant gains made by minorities in the last 40 years". Congress said that "second generation" barriers are a threat to voting rights.

Kagan said the case was evidently persuasive because 98 senators voted in favour of renewing the legislation while none voted against.

But Justice Antonin Scalia dismissed that. He said the Senate vote was a representation of political positions and suggested that for that reason it should be for the courts and not Congress to decide the issue.

"I don't think there's anything to be gained by any senator to vote against continuation of this act," he said. "It's a concern that this is not the kind of a question you can leave to Congress. There are certain districts in the House that are black districts by law just about now. And even the Virginia senators, they have no interest in voting against this … They are going to lose votes if they do not re-enact the Voting Rights Act."

The solicitor general, Donald Verrilli, representing the Obama administration in support of Section 5, called that position "extraordinary".

Verrilli noted that the 14th amendment to the constitution gives Congress the power to enforce protections of the right to vote. He said that power was a direct result of the civil war and the end to slavery, and therefore it was always understood that it would be focused on the former Confederate states.

Verrilli argued that Section 5 has a constraining effect that discourages states from more blatant attempts are distorting elections, and that things would be much worse without it.

"Everyone acknowledges that the Voting Rights Act made a huge difference in transforming the culture of blatantly racist vote suppression that characterised parts of this country for a century," he said. "Section 5 pre-clearance was the principal engine of that progress."

The chief justice, John Roberts, wondered why states like Alabama were singled out when liberal Massachusetts has the worst ratio of African American turnout against white turnout at elections, and the greatest disparity in voter registration.

"Is it the government's submission that the citizens in the south are more racist than the citizens in the north?" he asked Verrilli. The solicitor general said not.

The justice likely to be the swing vote, Anthony Kennedy, expressed scepticism about the continuing need for Section 5 and the fact that it is primarily directed at the old segregationist states. "Times change," he commented.

Justice Breyer said it was reasonable to single out states with a history of systematic discrimination.

"Of course this is aimed at states," he said. "What do you think the civil war was about?"

There was vocal support for the Voting Rights Act outside the court where hundreds of demonstrators chanted "Hell no, we aren't going back" and waved signs declaring "protect my vote".

Among them was Bruce Morgan, an activist in the National Association for the Advancement of Colored People (NAACP).

"The fact I have to come to Washington 55 years after the March on Washington tells you there's still a problem," he said. "When you still have people standing in line for six or seven hours because they're constraining your right to vote, there's no way the Voting Rights Act has done its job. They're making voting more difficult again."

The court is expected to hand down its decision before July.