Peru's ex-President Pedro Castillo has been detained, after his efforts to dissolve parliament instead ended in him being thrown out of office.
In a dramatic day in Lima, Mr Castillo was accused of plotting a coup in a last-gasp bid to avoid impeachment on corruption charges by Congress.
The move sparked international and local outrage, and lawmakers moved quickly to remove him from office.
His Vice-President Dina Boluarte was later sworn in as his successor.
She condemned her predecessor's move to dissolve Congress as an "attempted coup" and pledged to form a new cabinet of all political stripes.
Images run by local TV outlets showed Mr Castillo cooperating with prosecutors in police custody. He has reportedly been moved to a police-run prison, but Mexico says it is willing to offer him asylum.
The country's Foreign Minister, Marcelo Ebrard, said he was "very concerned" by Mr Castillo's detention, but said the former president had yet to make a formal request for asylum or aid from his government.
"Mexico regrets the latest events in Peru and wishes respect for democracy and human rights, for the good of that endearing sister nation," Mr Ebrard added in a post on Twitter.
Mr Castillo was removed from office by lawmakers on Wednesday after he gave an address on national television in which he declared a state of emergency and outlined plans to rule the country by decree.
He announced that he would dissolve the opposition-controlled Congress, a move which was met with shock both in Peru - several ministers resigned in protest - and abroad.
The head of the constitutional court accused him of launching a coup, while the US "strongly urged" Mr Castillo to reverse his decision.
Peru's police and armed forces released a joint statement in which they said they respected the constitutional order.
Mr Castillo's attempts to dissolve Congress came just hours before it was due to start fresh impeachment proceedings against him - the third since he came to office in July 2021.
Elected as a political outsider, he has lacked a power base in the country's fractured legislature - especially since his break from the Free Peru party in June to govern as an independent.
And his government has been consistently surrounded by chaos, with dozens of ministers appointed, replaced, fired or quitting their posts in little more than a year.
In his televised address, he said: "In response to citizens' demands throughout the length and breadth of the country, we have decided to establish an exceptional government aimed at re-establishing the rule of law and democracy."
He said that "a new Congress with constituent powers to draw up a new constitution" would be convened "within no more than nine months".
While running for the presidency, one of Mr Castillo's main pledges was to call a referendum for an assembly to write a new constitution, to replace the current text enacted in 1993 under Alberto Fujimori. He had called for a document that "has the colour, smell and flavour of the people".
But he has faced a steady stream of investigations on whether he used his office to enrich himself, his family and his closest allies, and critics called his move on Wednesday an attempt to avoid impeachment.
Congress, which is controlled by parties opposed to Mr Castillo, convened an emergency session after his speech and held the impeachment vote that Mr Castillo had been trying to prevent.
The result was overwhelming: 101 voted in favour of impeaching him, with only six against and 10 abstentions.
He was later detained by police and in photos - which were shared by police on Twitter but subsequently deleted - he could be seen sitting, seemingly relaxed, and chatting to others.
In a statement, Peru's public ministry said Mr Castillo had been detained "for allegedly committing a crime against the Powers of the State and Constitutional Order". He has yet to be formally charged.
His downfall was marked by some small street clashes in Lima, with supporters marching and tussling with police. One demonstrator held a sign saying: "Pedro, the people are with you".
Meanwhile, metal barricades were erected around the government palace and Congress in Lima, while police in riot gear stood guard.
Mr Castillo's Vice-President, Dina Boluarte, will now lead the country and has pledged to bring unity to the country's divided political scene.
A former lawyer who was something of a political unknown before being chosen as Mr Castillo's running mate, the 60-year old said she would govern until July 2026, which is when Mr Castillo's presidency would have ended.
"What I ask for is a space, a time to rescue the country," she said.
The US ambassador to Lima welcomed the new government, while the US state department said it would "support Peru under the unity government President Boluarte pledged to form".