Brazil's ex-President Luis Inácio Lula da Silva will not surrender to federal police at their southern HQ despite being ordered by a judge, reports say.

Lula was expected to surrender by late afternoon after the Supreme Court ruled he should not stay free while appealing against his corruption conviction.

It is not clear whether he will give himself up in São Paulo instead.

He says charges against him are politically motivated and designed to stop him from running from president.

He had been favourite to win the October poll.

In his order, federal judge Sergio Moro said 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.

He has been sentenced to 12 years in jail but the appeals process could take several more months or even years.

Several hundred Lula supporters have been rallying outside the metalworkers' union near São Paulo, where he is staying.

The Folha de São Paulo quoted Lula as saying in a brief phone conversation with the paper that he intended to remain at the metalworkers' union throughout the day.

An unnamed source in his Workers' Party told Reuters news agency he was waiting for a ruling on a last-minute appeal but it was not clear whether the ruling would come before the 17:00 deadline.

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

Who is Lula?

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

A former metalworker and trade union activist, he was the first left-wing leader to make it to the Brazilian presidency in nearly half a century.

While he was in office, Brazil experienced its longest period of economic growth in three decades, allowing his administration to spend lavishly on social programmes.

Tens of millions of people were lifted out of poverty thanks to the initiatives taken by his government and he left office after two consecutive terms (the maximum allowed in Brazil) with record popularity ratings.

What is Operation Car Wash?

In 2014, after Lula left office, prosecutors started investigating allegations that executives at the state oil company Petrobras had accepted bribes in return for awarding contracts to construction firms.

The investigation, dubbed Operation Car Wash, uncovered a huge web of corruption involving top-level politicians from a broad spectrum of parties taking kickbacks.

Lula himself was convicted of receiving a renovated beachfront apartment worth some 3.7m reais ($1.1m, £790,000), as a bribe by engineering firm OAS.

The defence says Lula's ownership of the apartment has never been proven and that his conviction rests largely on the word of the former chairman of OAS, himself convicted of corruption.

Lula has described the battle against his conviction and prison term as a continuation of his fight against Brazil's military rule, which came to an end in 1985.

"I did not accept the military dictatorship and I will not accept this dictatorship of the prosecutors," he told a gathering of supporters on Monday.

What happens next?

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 so 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.

What about the election?

Under the "clean slate law" passed in 2010, no one convicted of a crime upheld on appeal can run for elected office for at least eight years.

That law would rule Lula out from running for the presidency in October. However, exceptions have been made to the law before.

The decision as to whether Lula can stand for president will rest with the Superior Electoral Court (TSE).

The TSE will not make a decision on whether Lula can run or not until he has registered as a candidate and he has until 15 August to do so. So we may not know for months to come whether he will be able to stand.