The widely expected decision removes a cloud hanging over Brazil’s most uncertain election in decades - though Lula’s lawyers have said they would appeal an adverse decision to the Supreme Court.

“What is at stake here today is the equality of all citizens before the law and the Constitution,” Judge Og Fernandes told the court in his vote to declare Lula ineligible.

Judge Admar Gonzaga, who as a lawyer worked for Lula’s handpicked successor Dilma Rousseff’s 2010 election, cast the decisive vote in the 6-1 decision that sealed the leftist icon’s ejection from the presidential election.

Lula, Brazil’s most popular politician, is serving a 12-year sentence for a corruption conviction. His Workers Party registered him as its presidential candidate for the Oct. 7 vote anyway, saying he is innocent.

Lula is ineligible for office under Brazil’s “Clean Slate” law, which prohibits candidates from running if they have convictions that have been upheld on appeal.

Despite his conviction and several graft cases pending against him, Lula leads the race by a long stretch, with 39 percent of voter support, according to pollster Datafolha. His nearest rival, far-right candidate Jair Bolsonaro, has 19 percent.

Ads by the Workers Party calling on Brazilians to vote for Lula began to appear on social media on Friday, and will be shown on television as of Saturday when the race enters its final 35 days of campaigning.

A party statement said the court had bowed to the wishes of Brazil’s elites to stop Lula returning to office. The court had also ignored a recommendation by the United Nations Human Rights Committee to restore Lula’s political rights which he appeals his conviction, it said.

Vice-presidential running mate Fernando Haddad, a former mayor of Sao Paulo, is expected to head the ticket hoping to inherit the bulk of Lula’s votes.

The party has until Sept. 17 to swap their names on the ballot, though the court gave it 10 days to make the change.

The court also ruled that Lula should not appear in the Workers Party’s television and radio ads campaign until the ticket has been officially altered to remove him.

The court on Thursday had rejected another request by opponents of Lula to exclude his name from opinion polls.

Reporting by Ricardo Brito and Anthony Boadle; Editing by David Gregorio, Brad Brooks and Kim Coghill