Inmates in six Ecuadorian prisons have released 50 guards and seven police officers they had taken hostage, the prison service (SNAI) has said.
The 57 freed hostages are "undergoing medical evaluation" but appear to be in good health, according to SNAI.
Officials say the kidnappings were coordinated by criminal gangs angry at attempts to curb their power.
Two car bombs which went off near police buildings in the capital, Quito, have also been blamed on the gangs.
The authorities believe at least one of the incidents could be retaliation for a police search for weapons at one of the country's biggest jails.
Hundreds of police officers and soldiers carried out the search at Cotopaxi jail in Latacunga, about 55 miles (88km) south of Quito, as part of efforts to prevent further violence at the prison on Wednesday.
Normal activities have now been resumed in the six facilities, including a young offenders unit which was badly damaged by an arson attack. Officials have not offered any details as to how or why the officers were released.
"The measures we have taken, especially in the prison system, have generated violent reactions from criminal organisations that seek to intimidate the state," President Guillermo Lasso said on X, formerly Twitter, on Friday night.
Ecuador is facing growing violence linked to drug-trafficking gangs, which has put a huge strain on the under-resourced and overcrowded prison system.
Hundreds of inmates have been killed in deadly fights in Ecuador's overcrowded jails in recent years.
Such is the influence of narco-politics in Ecuador, its prisons are places of power - it's where those involved in drugs offences get locked away.
But they're also the control centres of many of the cartels and gangs now - so when inmates don't like what the authorities are doing, they make that known through violence and riots.
The country is less than two months away from the run-off round of presidential elections - a campaign that has been marred by violence and the assassination of a candidate.
Presidential front-runner Luisa Gonzalez said on Friday that she will wear a bulletproof vest while campaigning and will also accept the government's offer of military protection.
Meanwhile, criminal gangs on Friday detonated explosive devices on a bridge in the coastal province of El Oro.