Brazil's top electoral court has barred jailed former president Luiz Inácio Lula da Silva from running in this year's presidential election because of his corruption conviction.
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 7 October 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% of voter support, according to pollster Datafolha.
His nearest rival, far-right candidate Jair Bolsonaro, has 19%.
Ads by the Workers Party calling on Brazilians to vote for Lula began to appear on social media yesterday, and are being shown on television as of today as the race enters its final month 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 17 September to swap their names on the ballot, though the court gave it ten 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.
Last Thursday, the court rejected another request by opponents of Lula to exclude his name from opinion polls.