BRASILIA (Reuters) - Brazilian President Jair Bolsonaro on Twitter took a first swipe at political rival Luiz Inacio Lula da Silva on Saturday after the leftist former leader was released from prison, highlighting deep political divisions likely to flare up in the comings days.

Bolsonaro suggested Lula - who was president from 2003 to 2010 - was a "scoundrel" and called for his followers to rally around the government's right-wing agenda, saying they should not allow "the new phase of Brazil's recovery" to be derailed.

"Lovers of freedom and good, we are the majority. Without a north star and a directive, even the best troops become a band shooting at all sides, including friends," Bolsonaro wrote.

"Do not give ammunition to the scoundrel, who is momentarily free but full of guilt," he added, not referring to Lula by name.

A judge ordered that Lula be freed on Friday, after the country's top court issued a broader ruling ending the mandatory imprisonment of convicted criminals after they lose their first appeal. Lula had been imprisoned on a corruption conviction, bearing a nearly nine-year sentence.

Lula spent the night in the southern city of Curitiba, where he had been jailed but is expected to return to the Sao Paulo area on Saturday.

Exiting the prison to a cheering crowd of supporters in red for Lula's Workers Party, he called for a rally on Saturday at the metalworkers union on the outskirts of Sao Paulo where he got his political start, pledging to follow that up with a national tour.

Lula, who exited the presidency with sky-high approval ratings, is ineligible to stand for office until 2025 under Brazil's "Clean Record" law because of his conviction for taking bribes. But his release is expected to energize the left ahead of next year's municipal elections.

Under a Supreme Court ruling on Thursday, Lula and other convicted criminals can only be jailed after they exhaust their appeals.

Lula was imprisoned in 2018 after being found guilty of taking bribes from construction firms in return for public contracts. He has maintained his innocence and said the case against him was politically motivated.

In his first speech to supporters outside his jail in Curitiba on Friday, Lula vowed to fight to establish his innocence, accusing "rotten" police, prosecutors and judges of "working to criminalize the left."

(Reporting by Jake Spring)