"Only one thing will take me off the streets of this country, and it will be the day of my death," he told cheering supporters, many wearing the red T-shirts of his Workers' Party (PT).

"Until that moment, I will fight for a more just society. Whatever the outcome of the trial, I will continue fighting for the dignity of the people of this country."

Lula was joined on the podium by his handpicked successor Dilma Rousseff, who was impeached in 2016 for breaking budget rules.

"I am not going to speak today about my trial or about justice, because I have competent lawyers who have proven my innocence," he said.

"I come here to talk about Brazil," added Lula.

"I have the peace of the innocent, of those who did not commit any crime. Are they afraid of me coming back? They are afraid of the good things we did," he said, referring to his right-wing opponents.

Lula, Rousseff and leftist leaders say they are the victims of a plot by judicial, political and business sectors to sideline the PT.

High security

Lula was sentenced in July to 9.5 years behind bars after being convicted of corruption in Brazil's huge "Car Wash" graft scandal.

The court could decide whether Lula -- hugely popular during his two-term presidency from 2001-2010 -- can take part in the October 2018 presidential elections, in which he is currently the frontrunner.

Authorities in Porto Alegre have mounted a special security operation to keep opponents and supporters of Lula apart, amid fears of clashes.

Helicopters will overfly the courthouse and even ships are being used to protect the building, located adjacent to a river.

Lula will follow the ruling from his home in Sao Paulo.

Rousseff had earlier denounced what she called the "third stage of the coup" against Lula.

The first, she argued, was her impeachment, the second consisted of the austerity budget introduced by her successor Michel Temer and the third "aiming to destroy the PT and especially our leader."

Markets alert

Analysts said the markets were betting on Lula's sentence being confirmed by the court.

"Markets cannot hide their enthusiasm: a ruling against Lula, who has promised to revert part of President Michel Temer's business-friendly reforms, is widely seen as a fatal blow to his presidential bid," said Silvio Cascione in a note from the Eurasia consultancy.

The Sao Paulo stock exchange closed Tuesday down 1.22 percent, which analysts attributed to caution ahead of the verdict.

Whatever the verdict, the court decision will constitute a new test for Brazilian democracy.

"If Lula can't run, the election is very uncertain and we would have five or six candidates with the possibility of reaching the second round, which would make the 2018 elections the most unpredictable since the restoration of democracy (in 1985)," political scientist Mauricio Santoro of Rio de Janeiro State University told AFP.

In the most recent survey by Brazilian pollsters Datafolha, at the beginning of December, Lula had 34 percent of voter intentions, followed by the right-wing deputy Jair Bolsonaro, with 17 percent.