Festival fever swept the Brazilian capital as Luiz Inacio Lula da Silva was sworn in on Sunday for a third term as president, in a ceremony snubbed by departing leader Jair Bolsonaro, underlining the deep divisions the veteran leftist inherits.
Police on Sunday detained a man who had an explosive device and a knife. He was trying to enter Brasilia's esplanade for Mr da Silva's inauguration, Alan Campos from Brasilia's military police told Reuters.
The swearing-in capped a remarkable political comeback for Mr da Silva, 77, who returns to the presidential palace less than five years after being jailed on controversial corruption charges that have since been quashed.
In a sign of the scars that remain from Mr da Silva's brutal election showdown with far-right former army captain Mr Bolsonaro in October, security was exceptionally tight at the ceremony in Brasilia.
At least 8,000 police officers have been posted after a Bolsonaro supporter was arrested last week for planting a tanker truck rigged with explosives near the capital's airport, a plot he said aimed to "sow chaos" in the South American country.
Mr Bolsonaro left Brazil for the US state of Florida on Friday ― reportedly to avoid having to hand the presidential sash to his bitter enemy, as tradition dictates.
The snub has hardly dampened the party spirit for Mr da Silva and the 300,000 people expected at the New Year's Day ceremony, and a massive celebration concert that will feature acts ranging from samba legend Martinho da Vila to drag queen Pabllo Vittar.
Thousands of Mr da Silva’s supporters from around the country formed long lines to filter through the security cordon, yelling pro-da Silva chants as they waited.
"I'm excited beyond measure," retired teacher Zenia Maria Soares Pinto, 71, told AFP after travelling 30 hours by bus from the southern state of Santa Catarina.
"I have so much admiration for his humility, his commitment to ensuring the people live in dignity."
Ms Pinto was part of a crowd cheering for Mr da Silva outside the hotel where the former metalworker was staying.
Machine operator Valter Gildo, 46, called it a "historic day".
"Today marks the return of a working man to the presidential palace, someone who fights for social causes, for minorities, against racism and homophobia, a person who represents Brazil," Mr Gildo said.
Foreign dignitaries, including 19 heads of state, were in attendance as Mr da Silva, who previously led Brazil through a boom from 2003 to 2010, took the oath of office for a four-year term on Sunday afternoon.
They included the presidents of Latin American countries, Germany, Portugal and the king of Spain.
After being sworn in before Congress, Mr da Silva will travel by car ― traditionally a black convertible Rolls-Royce, although officials said that could be changed for security reasons ― to the ultra-modern capital's presidential palace, the Planalto.
There, he will walk up a ramp to the entrance and receive the gold-and diamond-embroidered presidential sash.
Organisers of the ceremony ― led by his wife Rosangela "Janja" da Silva ― have kept secret who will give Mr da Silva the sash in Mr Bolsonaro's absence.
It will be the first time since the end of Brazil's 1965-1985 military dictatorship that an incoming president does not receive the yellow-and-green sash from his predecessor.
Mr da Silva faces urgent challenges for Latin America's biggest economy, which looks little like the commodities-fuelled dynamo he led in the 2000s.
They include restarting economic growth, curbing rampant destruction of the Amazon rainforest and delivering on his ambitious agenda to fight poverty and inequality.
Vice President Geraldo Alckmin described the incoming administration's task as "herculean".
Markets are meanwhile watching nervously how Mr da Silva will fund his promised social spending, given Brazil's overstretched government finances.
Mr da Silva will face a Congress dominated by Mr Bolsonaro's conservative allies.
In a sign of how polarised the country remains, far-right hardliners have been protesting outside army bases ever since his narrow run-off win on October 30.
They have been calling for a military intervention to keep Mr da Silva from taking power.
The new president will have to act "assertively" in his first 100 days to show where "Mr da Silva Part Three" is headed, said political scientist Leandro Consentino.
"His election win was very tight, and he'll face a divided country and a combative opposition," Mr Consentino said.
"He'll have to lead a national unity government and restore the peace."