Former Brazilian President Luiz Inacio Lula da Silva has been convicted of corruption charges and sentenced to nine and a half years in prison.
The judge ruled he could remain free pending an appeal.
Lula has rejected claims that he received an apartment as a bribe in a corruption scandal linked to state oil company Petrobras.
He says the trial is politically motivated and has strongly denied any wrongdoing.
The case is the first of five charges against him.
Lula served eight years as president until 2011 and has expressed interest in running again in next year's elections for the left-wing Workers' Party.
On Wednesday, a judge found him guilty of accepting bribes from engineering firm OAS in the form of a beachfront apartment in return for his help in winning contracts with the state oil company.
In a statement, Lula's lawyers insisted he was innocent and said they would appeal.
"For more than three years Lula has been subject to a politically motivated investigation. No credible evidence of guilt has been produced, and overwhelming proof of his innocence blatantly ignored," they wrote.
The head of the Workers' Party, Senator Gleisi Hoffmann, also hit out at the ruling, saying it was designed to stop Lula standing for office.
She said the party would protest against the decision.
In theory, Lula is free to run in the presidential election until the legal process ends.
The BBC's Katy Watson in Rio says he remains a popular politician and the sentence will deeply divide Brazil.
The charges Lula faces relate to the Car Wash scandal, the nickname for Brazil's biggest ever corruption probe.
Operation Car Wash was launched three years ago amid escalating public anger over political corruption.
The investigation centres on firms that were allegedly offered deals with Petrobras in exchange for bribes, which were funnelled into politicians' pockets and party slush funds.
Lula, a former steel worker turned union leader, came to office as the first left-wing leader in Brazil in nearly half a century.
He was Brazil's most popular president during his tenure - former US President Barack Obama labelled him the most popular politician on Earth.
Unable to stand for a third consecutive term, he was succeeded by close ally Dilma Rousseff, who was later impeached.
Current President Michel Temer also faces corruption allegations and is resisting calls for him to step down.
Analysis: Justice served?
Katy Watson, BBC News, Rio de Janeiro
There are few people who polarise political debate as much as Lula. His sentence is no different.
While his supporters complain the case was politically motivated, his critics see this outcome as justice served.
Overseeing the case was Judge Sergio Moro. He's the man in charge of Operation Car Wash, the country's biggest ever corruption investigation and another divisive figure. He's a superstar crusader or a man on a mission to destroy Lula and the Workers' Party, depending on your viewpoint.
But for or against, this sentence just goes to show how far Operation Car Wash has come. Not even Brazil's most popular politician has been untouched by this.