Convicted felons in Iowa may be automatically stripped of their voting rights for life unless those rights are restored by the governor, a divided Iowa Supreme Court ruled Thursday.

The 4-3 decision permanently disenfranchises thousands of former offenders and upholds Iowa's status as one of the most restrictive states for voting by felons.

Democrats and civil-liberties advocates expressed disappointment in a court known for its 2009 ruling legalizing gay marriage and other progressive decisions.

"This ruling means that Iowa will continue to serve as a notorious outlier when it comes to restricting people'sright to vote," said Julie Ebenstein, an attorney with the American Civil Liberties Union's Voting Rights Project.

Iowa's top elections official, Republican Secretary of State Paul Pate, praised the ruling, saying it was in line with the constitution and state law.

Felons had long been disqualified from casting ballots and holding public office, although the court had not ruled definitively. At issue was the interpretation of an 1857 clause in the Iowa Constitution declaring that no "person convicted of any infamous crime shall be entitled to the privilege of an elector."

The ACLU brought a challenge on behalf of Kelli Jo Griffin, who was convicted of a nonviolent drug offense. The group argued that Griffin had not committed an infamous crime and she should not be disenfranchised.

Her attorneys urged the court to rule that only people who commit crimes that are an "affront to democratic governance" — such as treason and corruption — should be disqualified. The constitution's goal, they argued, was to protect the ballot box, not to punish offenders.

Chief Justice Mark Cady endorsed that approach in a 2014 decision that suggested only crimes that are serious and linked to election integrity were infamous. But he disavowed that ruling in Thursday's majority opinion, writing that it had been decided hastily before an election.

Cady wrote that he now sees little evidence to support that practice, saying the constitutional measure originated from common law that generally regarded all felonies as infamous. Also, Iowa lawmakers passed a law in 1994 that defined felonies as infamous crimes and haven't moved to change the standard, he noted.

"The legislative judgment was clearly expressed, and there is no scientific evidence or facts to undermine that judgment," he wrote.

The decision cannot be appealed since it involves the Iowa Constitution, not the U.S. Constitution.

Dissenting justices said the ruling would perpetuate a system that treats felons as second-class citizens and disproportionately limits the political power of the state's black population.

The decision will "disqualify thousands of Iowans from exercising the fundamental right to vote after they have fully satisfied their criminal sentences, even without a showing of nexus of the crime to the integrity of the electoral process," Justice Brent Appel wrote.

More than 56,000 felons have been disqualified from participating in Iowa elections. Civil-liberties advocates had hoped the case would result in most of them being able to vote in November, when Iowa could be a swing state in the presidential election.

Iowa Democratic Party Chairwoman Andy McGuire said the ruling "keeps Iowa on the extreme fringe of voter disenfranchisement."

Iowa, Florida and Kentucky are the only states with lifetime voting bans for felons unless their rights are restored by the governor.

About 20 ex-offenders have been restored annually since Republican Gov. Terry Branstad returned to office in 2011. On his first day, he issued an order requiring felons who have finished their sentences to apply to get their rights back, undoing an automatic restoration process that had been in place under the two prior Democratic governors. The change caused widespread confusion.

Griffin was charged in a state voting-fraud investigation after she voted in an uncontested 2013 municipal election in her hometown, Montrose. Griffin had completed her sentence and believed her voting rights were restored. Jurors acquitted her at trial, sparing the mother of four a possible prison sentence.

Branstad has defended his policy, saying it encourages offenders to pay restitution. He has moved to make the application process easier, although it remains a major barrier.

Appel said the decision leaves felons "subject to flip-flopping executive orders depending upon the political philosophy of the executive."