Brazil's former president Luiz Inácio Lula da Silva is starting a 12-year sentence for corruption after surrendering to police.
It follows a two-day stand-off that saw him take refuge in a steelworkers' union building after missing a court deadline to hand himself in.
The 72-year-old walked out of the office in his hometown, near Sao Paulo, and was taken away by police cars.
Scores of supporters had earlier blocked his car from leaving the scene.
Lula maintains he is innocent, but said he would comply with the arrest warrant against him.
Footage on Brazil's GloboNews showed Lula and his bodyguards pushing through the crowd outside the union building, in the town of Sao Bernardo do Campo.
He was then flown by police helicopter to the southern city of Curitiba to begin his prison sentence.
Demonstrators set off fireworks as the helicopter landed, and riot police fired tear gas to disperse the crowd. The fire department said eight people were slightly injured, one of them by a rubber bullet.
Lula was the frontrunner for October's presidential election, but his jailing leaves the race wide open.
The former metalworker and trade union activist is an iconic figure for the left in Latin America. He was the first left-wing leader to make it to the Brazilian presidency in nearly half a century.
What did Lula have to say?
Earlier on Saturday, flanked by his impeached successor as president, Dilma Rousseff, the 72-year-old delivered an impassioned 55-minute speech.
"I will comply with the order and all of you will become Lula," he told the crowd in Sao Bernardo do Campo. "I'm not above the law. If I didn't believe in the law, I wouldn't have started a political party. I would have started a revolution."
Promising to come out of his legal troubles "bigger and stronger", he said: "I was born with a short neck so I can keep my head high."
When he left the stage, he was carried on the shoulders of delighted supporters chanting "Free Lula!"
The soap opera ends - until the next episode
By the BBC's Katy Watson in Sao Paulo
It's been a dramatic few days in Brazilian politics - this in a country that's used to political intrigue. As Saturday went on, the situation felt like it was getting tense.
As protestors blocked the exits preventing Lula from leaving, several vans of federal police arrived and there was talk of riot police arriving, too.
But aware Lula's arrest could lead to confrontations, they weren't an overt presence. And in the end, Lula walked out and got into a car with nobody resisting his surrender.
This marks the end of another chapter in Brazil's political soap opera. But there's no question he'll feature in the next one. His influence will continue to dominate the upcoming presidential elections, even if he's barred from running himself.
What was Lula convicted of?
The charges against Lula came from an anti-corruption investigation known as Operation Car Wash, which has embroiled top politicians from several parties.
He was convicted of receiving a renovated beachfront apartment worth some 3.7m reais ($1.1m, £790,000), as a bribe from engineering firm OAS.
Lula says his conviction was designed to stop him from running for president again.
In an order issued on Thursday, federal judge Sergio Moro said Lula had to present himself before 17:00 local time (20:00 GMT) on Friday at the federal police headquarters in the southern city of Curitiba.
He missed that deadline and retreated to the union building in his hometown - triggering a two-day waiting game.
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.
Who is Lula?
Lula served as president from 2003-2011. Despite a lead in opinion polls ahead of October's election, he remains a divisive figure.
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 happens now?
Two last-minute appeals to have Lula's arrest warrant suspended failed.
Supreme Court Justice Edson Fachin rejected Lula's appeal on Saturday, a day after his appeal to the Superior Court was declined.
#Lula How long does a lunch last, when you're about to be jailed for 12 years?— Adèle Smith 🤔 (@adelesmith100) April 7, 2018
Under a 2016 law, defendants can be jailed if their conviction is upheld on a first appeal - as Lula's was earlier in the year.
The former president faces six separate pending trials for corruption.
As a convict Lula would normally be barred from standing for election in October, but Brazil's top electoral court reserves the final decision if and when he submits his candidacy.