The President of Ecuador was rescued by troops late last night who stormed a hospital in Quito where he had been taking refuge.
President Rafael Correa had been trapped inside for hours by renegade police protesting at government austerity measures, in what was the most serious challenge to his rule since he took office in 2007.
Two policemen died in the violent end to a standoff that shook the South American nation and brought a torrent of international condemnation from the White House to Havana.
The drama began when dissident police attacked Mr Correa during protests over proposed cuts to bonuses and a freezing of promotions.
He took refuge in a nearby hospital and accused opponents of trying to topple him in a coup.
Though some soldiers joined the protests, the military top brass stayed loyal and Mr Correa was rescued amid a blaze of gunfire shown live on television around the world.
'What loyalty, what support', an emotional Mr Correa, 47, shouted after returning to address cheering crowds from the balcony of his presidential palace in the capital.
'This will serve as an example for those who want to stop the revolution not through the ballot box but with weapons.'
The US-trained economist and close ally of Venezuela's Hugo Chavez took power in 2007, alienating foreign investors but winning approval ratings with populist policies like greater state control over natural resources.
Mr Correa has steadily accumulated more power, but yesterday’s chaos was a stark reminder of the OPEC nation's volatile history of economic crises and coups.
Street protests toppled three presidents in the decade before President Correa took power, but none of them enjoyed the popular support that he does.
Mr Correa irked foreign capital markets two years ago when his government defaulted on $3.2bn in global bonds.
Cash has been tight since as the nation relies on multilateral loans and bilateral lending to meet international financing needs.
Police angered by cut-backs led yesterday's protests, and some soldiers joined in.
A group of troops seized Quito's main international airport, halting flights for several hours.
The local Red Cross said at least 88 people were injured during the day's unrest.
The UN and governments across the Americas had thrown their support behind Mr Correa, with Washington backing him and calling for a peaceful resolution to the crisis.
Venezuela and Cuba also issued strong statements condemning the actions against Mr Correa.
Global oil prices rose to a seven-week high of near $80 a barrel, partly due to the turmoil in OPEC's smallest member.