Luiz Inacio Lula da Silva, former president of Brazil, has appeared in court to testify over his alleged entanglement in a sprawling corruption scandal that has thrown the country's political class into tumult.

Lula, 71, is the highest-profile defendant in the "Operation Car Wash" probe into a multi-billion-dollar bribery scheme in which politicians and officials allegedly handed out public contracts in exchange for kickbacks.

He is accused of allowing corruption to flourish between 2003-2010 during his two terms as president and of personally benefiting from the schemes, including receiving a beach apartment in return for helping the OAS construction firm win government contracts.

The former president, whose supporters had gathered in the city of Curitiba hours before his arrival at the courthouse, has repeatedly denied all charges.

"I consider this trial illegitimate and the accusation a farce," he told Judge Sergio Moro at the hearing, video released afterwards showed.



He said prosecutors were accusing him "based on allegations in the press."

A ruling by Moro, who has spearheaded Brazil's biggest-ever corruption probe, is not expected until July.

Al Jazeera's Teresa Bo, reporting from Curitiba, said that there was heavy presence of security forces outside the courthouse as there were fears that clashes could happen between the Lula supporters and those who support Moro and see the judge as a champion in the fight against corruption.

RELATED: Lula says prosecutors want to end his career

Bo said that ahead of Lula's appearance at the court, his lawyers had tried to postpone the hearing.

"They said that they never had enough time to review the over-100,000 pages that are attached to this case. They also tried to get Judge Moro removed from this case, saying that he isn't impartial."

The investigation centres on construction firms who have already admitted to paying billions in kickbacks in return for lucrative contracts at state-run oil company Petrobras.

Campaign-style rally

The investigation has greatly expanded since it began three years ago and now encompasses several state-run companies.

More than 90 powerful businessmen and politicians have been convicted, while scores of sitting federal congressmen and one-third of President Michel Temer's cabinet are being probed.

Thousands of Lula supporters descended on Curitiba overnight, mostly members of activists groups and unions, arriving in chartered buses from across the country.

They set up makeshift tents along railroad tracks a few kilometres from the federal courthouse.

As soon as he got out of court, Lula went to a campaign-style rally with supporters.



He reiterated his plans to seek a third term next year.



"I am preparing to return as a candidate," he said. "I want to show that the elite is not competent to fix this country but that the steel worker... will manage."

During his terms in office, Lula - Brazil's first working-class president - greatly expanded the nation's social safety net.

Al Jazeera's Bo said that Lula is arguably Brazil's most popular politician.

"Supporters we talked to here say that the country's poor were better off with Lula, that the country was developing faster and distribution of wealth was fairer,' she said.

Helped by a booming economy and an innovative cash-transfer programme, his administration helped lift tens of millions of people out of poverty and into the middle class.

When he left office in 2010, Lula had an 83 percent approval rating.

If he is convicted in any of the trials, and if the ruling is upheld by a second court, he will be legally disqualified from running for office and likely go to prison.