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.
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.