Ecuador's ousted President Lucio Gutierrez has been granted political asylum by Brazil, a day after he was removed from office by Congress.
Opponents accused Gutierrez of acting like a dictator
Mr Gutierrez has taken refuge in the Brazilian embassy in the capital, Quito, and is expected to be allowed to fly to Brazil later.
Vice-President Alfredo Palacio, sworn in on Thursday as the new president, has ordered Mr Gutierrez's arrest.
Mr Gutierrez was ousted following a week of escalating protests.
Protesters were angered by his attempts to overhaul the Supreme Court and apparently pack it with supporters. The court had always been dominated by Mr Gutierrez's critics.
Formerly Gutierrez's vice-president
Says oil money used to pay debt should be redirected at Ecuador's social problems
The former president was removed by a unanimous vote in Congress over the violent crackdown on the demonstrations, in which at least one person was killed.
Mr Palacio says he wants to reform the political system and has suggested convening an assembly to write a new constitution.
A Brazilian foreign ministry spokesman told the BBC that Mr Gutierrez had been granted political and territorial asylum and could now leave for Brazil.
Ambassador Sergio Florencio was negotiating Mr Gutierrez's safe passage from the embassy to Quito airport, he added.
Earlier, the army closed the airport, while President Palacio ordered Ecuador's borders to be sealed.
Ecuador has a history of political instability. It has had seven presidents since 1996 - three of them, including Mr Gutierrez, were forced out of office.
BBC regional analyst Simon Watts says the downfall of Lucio Gutierrez is the latest episode in a battle in Latin America between left-leaning presidents and the traditional elites that oppose them.
Mr Gutierrez came to power as a populist, anti-corruption left-winger in 2002, but lost the backing of many supporters by implementing free-market policies.
He forged close links with the powerful indigenous movement.
But, faced with economic difficulties, the president opted to follow the recommendations of the International Monetary Fund.
That lost him the support of his indigenous allies and his political weakness encouraged Ecuador's traditional parties to try to get rid of him.