Ecuadorean army troops have stormed a hospital in Quito and rescued President Rafael Correa, who had been trapped inside and surrounded by renegade police protesting against government austerity measures.
Mr Correa arrived back at the presidential palace in the capital, where local television images showed a large crowd of supporters cheering and waving Ecuador's flag.
He said one police officer had "fallen" during fighting around the hospital where he remained for hours during a day of turmoil in the South American nation.
He had been freed moments earlier amid gunfire after soldiers raided the building where he spent most of the day.
Mr Correa had been prevented from leaving the police hospital after he was attacked with teargas as he attempted to negotiate with the police.
Walking on crutches after a recent operation, he arrived at a police barracks to talk about a strike over pay but was jostled and pushed by angry policemen. He was then fired on with teargas.
For the next few hours, nothing was heard from the president and rumours circulated that he was being held against his will. At 6pm, Mr Correa telephoned state television station ECTV to confirm that the police had taken away his bodyguards and he had been "practically kidnapped".
Police chiefs denied this but protesters attempting to free him were also fired upon with teargas as they tried to reach the hospital.
Mr Correa remained defiant in the face of the police action, saying: "I will not take a single step back. I will not sign any agreement under pressure. I would die first. I thank my compatriots for their support and ask citizens to remain calm."
As night fell in Quito, the capital faced the unprecedented situation of the army and police fighting each other in the streets. At 9pm, the army attacked the police guarding the hospital with teargas and rubber bullets. Several soldiers are reported to have been injured in the fighting.
The president was seen leaving in a convoy half an hour later and returned to the presidential palace where a crowd of supporters had gathered.
He said from the palace: "This has been a very sad day."
He quickly moved to blame former President Lucio Gutierrez, who himself was removed in a coup in 2005.
"Lucio Gutierrez's people were behind this. His supporters have manipulated it all. They twisted everything in a conspiracy."
He then criticiced the policemen who held him, labelling them "cowards". He vowed to continues with his policies, adding: "Nobody will stop the citizen's revolution. We will never give in."
World leaders have rallied around Mr Correa. Venezuelan President, a close ally, condemned the "coup attempt", while Bolivian President Evo Morales spoke of a "vengeful conspiracy" against Mr Correa, comparing the situation with the coup d'etat in Honduras earlier this year.
This unprecedented situation began with a dispute over police pay.
Ecuador woke up on Thursday to news that thousands of police officers had decided to strike in protest at a public service law passed by the country's Assembly which removed bonuses for good performance and long service.
For most of the day, Ecuador was without a working police force as policemen mounted a nationwide strike, blockading bridges and seizing control of Quito airport. Countless robberies were reported at shops and banks in Quito and Guayaquil, Ecuador's largest city. In one incident in Guayaquil, a mob of 30 people armed with hammers looted an electronics store. Police chiefs and army chiefs meanwhile refused to support the strike and pledged support to the president.
According to the Red Cross, 51 people have been injured in the protests and there has been at least one unconfirmed death. A state of emergency was declared in the early afternoon and the army was deployed to remove barriers and reopen the airport. The government station ECTV then assumed control of all news communications in a controversial move. This prompted an angry mob to storm the station, breaking glass and assaulting security men.
Fighting continues between the police and army.