Brazil's former President Luiz Inácio Lula da Silva has been freed from jail.

A judge ordered the release of Lula after the Supreme Court ruled that convicted criminals should go to prison only if they have exhausted their appeal options.

He was mobbed by supporters outside a prison in the city of Curitiba where he has been held for a year and a half on corruption charges.

The left-winger led Brazil between 2003 and 2010 and remains popular.

"I didn't think that today I could be here talking to men and women that during 580 days shouted good morning, good afternoon or goodnight, no matter if it was raining or 40 degrees (Celsius)," Lula told the crowds.

He vowed to establish his innocence and criticised what he called the "rotten side of the judicial system" for "working to criminalise the left".

He was favourite to win last year's presidential election but was imprisoned after being implicated in a major corruption scandal. The race was won instead by far-right candidate Jair Bolsonaro.

Lula will be barred from standing for office because of his criminal record.

He has consistently denied all the accusations against him and claims they are politically motivated.

How did the release come about?

Justices voted to reinterpret the country's penal code in a decision issued on Thursday.

It overturns a three-year-old rule which mandated immediate prison time for convicted criminals after they lost their first appeal.

Tags: