Former Brazilian president Luiz Inacio Lula da Silva has been taken into police custody after a tense showdown with his own supporters.

It comes after an intense three days that underscored raw emotions over the incarceration of a once wildly popular leader who has been engulfed by corruption allegations.

Just hours earlier, da Silva told thousands of supporters that he would turn himself in to police, but also maintained his innocence and argued his corruption conviction was simply a way for enemies to make sure he does not run - and possibly win - re-election in October.

When he first tried to leave to turn himself in, however, dozens of supporters blocked a gate where a car carrying da Silva was trying to exit.

"Surround, surround (the building) and don't let them arrest him," chanted supporters. After a few minutes of tense words between guards and supporters, the former president got out of the car and entered the metal workers union headquarters where he had been holed up.

Police vehicles surrounded the union that was the birthplace of da Silva's rise to power, raising the fears of clashes. Da Silva emerged a second time shortly after nightfall, this time surrounded by bodyguards who pushed back scores of supporters who tried to stop his advance.

The dramatic scene was the latest development in a whirlwind series of days, which began when the Supreme Federal Tribunal, the country's top court, ruled against his petition on Thursday to remain free while he continued to appeal his conviction.

Judge Sergio Moro, who oversees many of the so-called "Car Wash" cases, then ordered an arrest warrant for da Silva, giving him until 5pm Friday to present himself to police in Curitiba, about 260 miles south-west of Sao Bernardo do Campo, and begin serving his 12-year sentence.

Da Silva, who Brazilians simply call "Lula", did no such thing. Instead, he hunkered down with supporters in the union headquarters.

"The police and 'Car Wash' investigators lied. The prosecutors lied," said da Silva, as a few thousand supporters cheered.

"I don't forgive them for giving society the idea that I am a thief," he continued.

Still, da Silva said he would turn himself in "to go there and face them eye to eye. The more days they leave me (in jail), the more Lulas will be born in this country."

While da Silva spoke, some people cried while others chanted "Free Lula!" When he finished speaking, a sea of supporters carried him on their shoulders back into the building.

Mauricio Santoro, a political science professor at the State University of Rio de Janeiro, said that by not complying with the order on Friday, da Silva "wanted to demonstrate strength and popularity, showing that he is a political leader capable of gathering a crowd in his support."

Choosing the metal workers union to take refuge, and not the Workers' Party headquarters, was also significant, said Mr Santoro.

"It shows that he wants to emphasise his trajectory as leader of a social movement, rather than his role as leader of a party marked by allegations of corruption," he said.

Last year, Moro convicted da Silva of trading favours with a construction company in exchange for the promise of a beachfront apartment. That conviction was upheld by an appeals court in January. The former president has always denied wrongdoing in that case and in several other corruption cases that have yet to be tried.

Still, his jailing marks a colossal fall from grace for a man who rose from poverty to power against steep odds in one of the world's most unequal countries.

Born in the hardscrabble northeast, da Silva rose through the ranks of the union in the country's industrial south. In 1980, during the military dictatorship, he was arrested in Sao Bernardo do Campo for organizing strikes. He would spend more than a month in jail.

After running for president several times, in 2002 da Silva finally won. He governed from 2003 to 2010, leaving office an international celebrity and with approval ratings in the high 80s.

Former US president Barack Obama once called da Silva the "most popular politician on Earth".

Workers' Party leaders insist that da Silva, 72, will still be the party's candidate in October. Technically, being jailed does not keep him off the ballot.

In August, however, the country's top electoral court makes final decisions about candidacies. It is expected to deny da Silva's candidacy under Brazil's "clean slate" law, which disqualifies people who have had criminal convictions upheld. Da Silva could appeal such a decision, though doing so from jail would be more complicated.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.