A Brazilian judge has ordered that the former President Luiz Inácio Lula da Silva turn himself in to police by late afternoon on Friday to begin serving a 12-year sentence for corruption.

On Thursday, the Supreme Court ruled against Lula’s plea to remain free while he appealed against his conviction.

Lula claims the charges are politically motivated, and designed to prevent him from running for president in October.

He had been the favourite to win.

In his order, Federal Judge Sergio Moro said that the 72-year-old must present himself before 17:00 local time (20:00 GMT) on Friday at the federal police headquarters in the southern city of Curitiba.

Judge Moro said that a special cell “was prepared in advance… in which the ex-president will be separated from other prisoners, with no risk for his moral or physical integrity”.

After the judge’s announcement several hundred of Lula’s supporters rallied outside the metalworkers union near São Paulo.

The charges came from an anti-corruption investigation known as Operation Car Wash, which has implicated top politicians from several parties.

Lula served as president between 2003 and 2011. Despite a lead in opinion polls ahead of October’s election, he remains a divisive figure.

Outside the metalworkers union, hundreds of people had gathered in a bit of a scramble – the rally was hastily brought forward from Friday after the arrest warrant was issued. People were carrying placards saying “Down with the coup” and “No to prison”.

Leaders of social movements and unions spoke to the crowd, telling them that they weren’t going to let Lula get arrested. They were prepared to put up a fight.

The question many people are wondering is whether Lula will give himself up voluntarily or whether he will make a show out of this and refuse to bow out in silence.

The Brazilian legal system usually goes at a glacial speed – so the pace of this process has surprised everyone. Brazil is in a state of political crisis and it’s likely to get worse in the coming days.

Although he has been told to turn himself in, it is not certain that he will go to jail for 12 years.

He has not exhausted his appeals yet. There are two higher courts which he can still turn to, the Superior Court and the Supreme Court – the latter has only ruled for far on whether he should go to jail pending further appeals, rather than on the underlying case.

Neither of those courts would re-examine whether Lula was guilty of corruption. They would look into whether legal procedures were followed correctly and whether his constitutional rights were breached.

This process could take months or even years. If either court were to rule in Lula’s favour, his conviction could be annulled and he would be released.