Brazil's top electoral court has ruled that jailed former President Luiz Inácio Lula da Silva cannot run as a candidate in the presidential election because of his corruption conviction.
Judges voted against his running in October's ballot by a majority of six votes to one in the seven-member court.
Lula, 72, was leading in polls ahead of the vote despite serving a 12-year jail term for accepting a bribe.
His legal team has said they will appeal against the court's decision.
Brazil's Workers' Party (PT) later responded to the court's decision in a statement, saying it would "fight by all means" for Lula's candidacy.
"We will present all appeals before the courts for the recognition of the rights of Lula provided by law and international treaties ratified by Brazil," the statement said, adding: "We will defend Lula in the streets, with the people."
Lula's conviction for money laundering and corruption was upheld in January. In Brazil, no one convicted of a crime upheld on appeal can run for office.
However, exceptions have been made to the law before.
In declaring Lula ineligible to stand on Friday, one judge said: "What is at stake here today is the equality of all citizens before the law and the Constitution."
What about Lula's convictions?
Lula was convicted of receiving a renovated beachfront apartment worth some 3.7m reais ($1.1m; £790,000) as a bribe by engineering firm OAS.
He denied wrongdoing and said his conviction was part of a plot to prevent him returning to power.
The former president is the most high-profile person convicted in the sweeping Operation Car Wash anti-corruption investigation.
Despite his jail sentence, PT voted to nominate Lula as its candidate last month.
Lula reportedly chose Fernando Haddad, former mayor of São Paulo, to run for the PT should he be prevented from doing so.
Who is Lula?
Serving as president from 2003 to 2011, Lula presided over a surge in economic growth and major social programmes that left him with an 87% approval rating on leaving office.
But the former leader surrendered to police in April after his corruption conviction.
An appeal in January not only saw the court uphold his original conviction, but also increase the length of the sentence by two-and-a-half years.
Before Friday's court judgement on whether he could run, Brazil's prosecutor general filed to bar his candidacy due to the law prohibiting those who have lost appeals against their conviction from standing.
Despite this, recent polls reportedly showed that around one-third of Brazilians would back Lula if he were allowed to run, which would make him the front-runner in October's vote.