Brazil’s ex-President Luiz Inacio Lula da Silva, better known as Lula, is to remain in prison after a day of legal wrangling.

An on-call judge ruled Sunday  that Lula should be released, but Judge Joao Pedro Gerbran Neto rejected this.

Eduardo Thompson Flores, the head of the federal court that convicted Lula, has now stepped in and said that there is no legal basis for his release.

Lula says he is innocent and the case is politically motivated.

His conviction was part of an anti-corruption investigation known as Operation Car Wash, which has implicated top politicians from several parties.

The initial announcement by Rogerio Favreto – the weekend duty judge – came after members of Lula’s Workers Party challenged his jailing in an application on Friday.