The left-wing former leader, known as Lula, was greeted with rapturous applause from crowds of supporters as he walked out of the jail on Friday.
He was held in a prison in the city of Curitiba on corruption charges.
A judge ordered his release after a Supreme Court ruling that defendants should only be imprisoned if they have exhausted their appeal options.
Lula is one of several thousand convicts who could benefit from the ruling.
The 74-year-old ex-president, who led Brazil between 2003 and 2010, is seen as a leftist icon in the country. As he left the prison, he pumped his fist in the air as a victory sign.
"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]," he told the crowds.
He also promised to prove his innocence, before hitting out at the "rotten side of the judicial system", which he accused of "working to criminalise the left".
Lula 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.
Criticising Mr Bolsonaro's economic policies, Lula vowed to keep fighting for impoverished Brazilians.
"People are hungrier, they have no jobs, people work for Uber or delivering pizzas on a bike," he added, specifically criticising insecure work and the gig economy.
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.
For Lula's supporters, this feels like vindication - he's a politician who stirs emotions and those who back him feel that this has been a political witch-hunt from the very beginning.
There's no guarantee Lula will remain free forever - he may not win the appeals that are left - and he's also been accused of corruption in other cases which he will have to face justice for.
But with Lula now free, it will strengthen the left in Brazil - and harden the right. President Bolsonaro doesn't hide his disdain for Lula and millions of people agree - the anger towards Lula and the Workers Party is what propelled Mr Bolsonaro to power in the first place.
More about: Brazil