Supporters of Luiz Inácio Lula da Silva, Brazil’s jailed former president, hope that he may soon be released from prison following an extraordinary legal skirmish that almost saw him freed at the weekend.

Lula – who is serving a 12-year sentence for money laundering and corruption – has consistently proclaimed his innocence, saying his conviction was a politically-motivated attempt to stop him running for October’s presidential elections.

The former president remains the country’s most popular leader in recent decades, and leads the election race, even though his conviction is widely understood to make him ineligible – although his party disputes this.

On Sunday, Rogério Favreto, a judge covering the weekend at an appellate court in Porto Alegre, southern Brazil, ordered that Lula be freed three times following a legal move by three lawmakers from Lula’s leftist Workers’ party – who argued that his pre-candidature for October’s presidential elections merited his release.

But each time Favreto was overruled, as bewildered Brazilians on social media compared the legal drama to a World Cup penalty shootout.

On Sunday, Moro challenged Favreto’s decision, even though he is on holiday. Carlos Thompson Flores, the court president, finally ruled that Lula should stay jailed, bitterly disappointing crowds of supporters who had gathered in front of the Federal Police building in Curitiba, where he is being held, and other cities.

Deepening the sense of uncertainty, the judges for Democracy Association issued a statement in support of Favreto’s decision but the National Union of Federal Judges came out against it. Brazilian media said Favreto had been a member of the Workers’ party for 19 years.

Trump of the tropics: the 'dangerous' candidate leading Brazil's presidential race

Read more

Jair Bolsonaro, an extreme rightwing former army captain polling second to Lula told the Valor Econômico newspaper that Brazil was in a “worse situation than pre-1964”, when an army coup installed a 21-year military dictatorship.

The Eurasia consulting outfit said it expected Lula to remain imprisoned and unable to stand in October’s elections. Others were not so sure.

“If we observe the strict juridical rules without any political influence, I believe he should not be released,” said Leonardo Pantaleão, a criminal lawyer and penal law professor.

But the supreme court could change its ruling that those convicted by an appellate court serve jail time rather than remaining free while lengthy appeals unwind when it returns from recess in August, he said, or decide his sentence was unlawful. That could mean Lula’s release.

Pantaleão said Sunday’s unprecedented legal drama eroded trust in the legal system among Brazilians, who already regard Michel Temer, the president, and Congress with contempt after graft scandals.

“When a society looks at its executive power with distrust, its legislature power also with distrust, and now its judicial power with distrust, there is little hope,” he said.