President Rafael Correa of Ecuador has been rescued from a siege at the hands of rebel police in the capital Quito.
He returned to the Presidential Palace where he addressed a crowd of thousands of jubilant supporters from the balcony, saying he had been through the saddest day of his government.
The left wing leader had been holed up in a hospital, barricaded in by renegade police after what he described as an attempted coup.
There was anger at cuts to bonuses and benefits as part of austerity measures.
Soldiers loyal to the president launched an assault from outside the hospital. Shots were heard as they took on the rebels, amid fierce fighting.
The president was freed. In his speech he said one policeman had “fallen” in the unrest.
In a day of turmoil, President Correa says he was attacked by police protesters. He was seen struggling for breath and suffering from the effects of tear gas.
The disturbances also spread to Guayaquil in the south and other cities. Neighbouring Peru and Colombia closed their borders.
Other Latin American countries and the US declared their support for the beleaguered president.