Brazil’s ex- President Luiz Inacio Lula da Silva was released from prison on Friday in Curitiba, southern Brazil.

As Lula walked out of prison, he was greeted by hundreds of supporters wearing red vests emblazoned with his face outside the federal police headquarters in the city of Curitiba, where he has been imprisoned for 580 days.

The former President was serving his sentence in the Federal Police headquarters in Curitiba.

Lula thanked party militants, while delivering speech to the crowd who had camped outside throughout his imprisonment, and attacked the “rotten side” of the police, prosecutors, tax office and justice system for jailing him.

The order came a day after the country’s Supreme Court overturned a law that required the imprisonment of convicts after they lose their first appeal.

Lula raised a defiant fist of victory in the air to the cheers of a crowd of supporters and members of his Workers Party who waved red flags and held “Free Lula” banners,  Aljazeera news reported.

Lula said that he has called for a rally on Saturday in Sao Paulo before he planned to embark on a national tour.

On Thursday, Brazil’s supreme court ruled defendants could only be imprisoned after all appeals to higher courts had been exhausted, paving the way for Lula and another 5,000 prisoners to be freed.

In June this year, supreme court had rejected two habeas corpus requests by Lula – who has been imprisoned on a corruption conviction for over a year – while postponing debate on the behaviour of a former judge who convicted the leader and was now the South American nation’s Justice Minister.

In Brazil, a case can be appealed three times — to the local court, the Superior Court of Justice (STJ) and the STF.