Lula is serving 12-year prison sentence for taking bribes from a Brazilian construction company.

A Brazilian appeals court judge has overruled an order to release imprisoned former President Luiz Inácio Lula da Silva.

In a surprising ruling on Sunday, appelate Judge Rogerio Favreto ordered the popular leftist politician, who is serving a 12-year prison sentence for corruption, freed.

But the order was blocked by Federal Judge Sergio Moro, who sent Lula to prison on the corruption conviction.

Moro declared the decision by Favreto, who served in the justice ministry under Lula, “monocratic”.

Another appeals court judge, Joao Pedro Gebran Neto, then intervened, ordering Lula to remain in jail and forbidding federal police from abiding by Favreto’s earlier ruling.

Gebran Neto is the judge in charge of overseeing Lula’s case at the Fourth Federal Regional Tribunal and a legal analyst said his decision supersedes the other judge’s.

Lula, who was convicted of accepting a seaside apartment as a bribe from Brazilian construction company OAS, has been battling to overturn his 12-year sentence in the hopes of making another presidential bid in elections in October.

Despite his jailing, Lula has consistently led presidential polls.

Whether Lula can run in the October election has yet to be decided by Brazil‘s electoral court next month.

Lula insists he is innocent and has branded the accusations of accepting the apartment as a conspiracy aimed at thwarting his electoral bid.

His everyman style and unvarnished speeches electrified masses and eventually won him two terms as president, from 2003 to 2011, when he oversaw robust economic growth and falling inequality amid a commodities boom.

He left office with a sky-high approval rate of 83 percent.