Ecuadorean troops stormed a hospital in Quito late on Thursday and rescued President Rafael Correa, who had been holed up surrounded by renegade police protesting against government austerity measures.
Correa arrived back at the presidential palace in the capital, where local TV images showed a large crowd of supporters cheering and waving Ecuador's flag.
Amid heavy gunfire, he had been freed after soldiers raided the building where he had spent most of the day.
Dissident police had earlier attacked Correa, prompting the 47-year-old leftist leader to seek refuge in the hospital, where he accused rivals of trying to topple him in a coup.
The US-trained economist and friend of Venezuela's socialist firebrand Hugo Chavez took power in 2007, alienating foreign investors but winning approval ratings with populist policies like greater state control over natural resources.
The United Nations and governments across the Americas threw their support behind Correa, with the White House backing him and calling for a peaceful resolution to the crisis.
Global oil prices rose to a seven-week high of near $80 a barrel, partly due to the turmoil in OPEC's smallest member.