SAO PAULO (AP) — A majority of justices on Brazil's electoral court voted late Friday to bar ex-President Luiz Inacio Lula da Silva from running in October's presidential election, virtually ending any chance that the front-runner will get on the ballot.

The decision, while long expected, leaves tens of millions of voters without a candidate and adds uncertainty to the race to lead Latin America's largest nation.

After several hours of debate late Friday, five justices had voted against da Silva's candidacy and just one in favor. One more was still to vote, though the majority was enough to seal da Silva's fate.

Supreme Court Justice Luis Roberto Barroso cast the first vote, saying barring da Silva was "very simple" due to the conviction and upheld appeal.

"There is no margin here for the electoral court to make any other evaluation but the one showing there is a conviction, and that conviction matters in the candidate's eligibility" to run, said Barroso.

Justice Edson Fachin disagreed, citing a recent call by a U.N. human rights committee calling for da Silva to be allowed to run while he appeals his conviction.

While justices were debating, the Workers' Party put out ads on its social media channels featuring da Silva, holding to a strategy to keep the former president front and center as long as possible.

Da Silva was wildly popular as president of Latin America's largest nation between 2003 and 2010. U.S. President Barack Obama once called him the "most popular politician on earth." But da Silva and his Workers' Party have lost much of that appeal over the last several years amid a sprawling corruption probe that has ensnared many top businessmen and politicians, including da Silva.

Da Silva, serving a 12-year-sentence for corruption and money laundering, is the front-runner despite being in jail. Under Brazilian law, da Silva is ineligible to run because his conviction was upheld on an initial appeal. But da Silva and supporters had hoped the Supreme Electoral Tribunal, which makes final decisions on candidacies, would allow him to run.

Da Silva has long argued that he should be allowed to run because his conviction was a sham. Judge Sergio Moro convicted da Silva of trading favors with construction company Grupo OAS in exchange for the promise of a beach house apartment.

He said the Workers' Party should replace da Silva within 10 days, and he should not appear as a presidential candidate in free airtime that is given to political parties on nationwide TV and radio starting on Saturday

Da Silva's lawyers complained the court was rushing a decision because they submitted their defense only on Thursday, noting that the court rarely holds sessions on Fridays.

In a statement late Friday, the Workers' Party said it would appeal. Earlier this year, the Supreme Federal Tribunal, the nation's highest court, denied a petition by da Silva to get out of prison while he continued to appeal.

With da Silva out of the race, former Sao Paulo Mayor Fernando Haddad was expected to take his place on the Workers' Party ticket. Currently Haddad is candidate for vice president. Polls show tepid support for his bid as replacement, but the party hopes da Silva's popularity could boost the former mayor's hopes.

On Saturday, Haddad was scheduled to visit Garanhuns, a city in Brazil's impoverished Northeast where da Silva was born.