Mutinying soldiers in Ivory Coast's second largest city Bouake released the defence minister after opening fire on the governor's house where he was staying as a two-day troop revolt came to a violent stand-off.
Defence Minister Alain-Richard Donwahi was trapped inside by the shooting late on Saturday, unable to head back to the commercial capital Abidjan. But after several hours Donwahi, other officials, and journalists were allowed to leave the home.
The defence chief went immediately to the airport to fly back to Abidjan.
The incident came minutes after Ivory Coast's President Alassane Ouattara went on national television to say a deal with the troops to end the revolt had been reached.
In addition to Donwahi, the deputy commander of the elite Republican Guard and the mayor of Bouake had been trapped inside the residence.
A crowd of angry soldiers massed outside the house loudly shouting that they wanted their bonuses paid immediately, not next week.
Journalist Ange Aboa, who was inside the home, told Al Jazeera the troops then opened fire with with Kalashnikov assault rifles and rocket-propelled grenades.
"We tried to save our lives - it was a disaster," he said. "There was gunfire and everybody ran away."
The two-day mutiny by soldiers spread quickly in nine cities across Ivory Coast with troops demanding higher salaries and improved living conditions.
Speaking to his ministers and reporters, Ouattara said the government had agreed to take into account the soldiers' demands concerning bonus payments and living and working conditions.
"I would like to say that this manner of making demands is not appropriate. It tarnishes the image of our country after all our efforts to revive the economy," Ouattara said.
Ouattara did not give details of the deal offered to the mutineers in his brief televised comments.
Soldiers in Bouake appeared furious after his announcement with one mutineer saying: "The president must tell us the date we will be paid and the amount we will be given."
Earlier, a member of the uprising said mutinying soldiers would return to their barracks.
"It's over," Sergeant Mamadou Kone told the Reuters news agency. "Some of our soldiers will remain in place to manage the security of shops and banks, but the majority of soldiers will return to barracks beginning tonight."
Unrest linked to the mutiny was witnessed in cities across the country, including the commercial capital of Abidjan, where gunfire rang out at the defence ministry after soldiers entered the city's military headquarters.
Abidjan is a city of nearly five million residents where the president, administration and parliament are based.
Rogue soldiers also erected makeshift barricades around the nearby military headquarters, leaving all roads leading to the camp gridlocked with traffic and hampering access to several neighbouring districts.
The uprising began early on Friday when disgruntled soldiers - mainly former rebel fighters - seized Bouake. The mutiny then spread to numerous other cities and towns.
Ivory Coast - French-speaking West Africa's largest economy - has emerged from a 2002-11 political crisis as one of the continent's rising economic stars.
However, years of conflict and a failure to reform its army - thrown together from a patchwork of former rebel fighters and government soldiers - have left it with an unruly force hobbled by internal divisions.
Nearly all of the mutineers appeared to be former members of the New Forces rebellion, which had used Bouake as its de facto capital and controlled the northern half of Ivory Coast from 2002 until the country was reunited following a 2011 civil war.
Donwahi arrived in Bouake in the early afternoon accompanied by Lieutenant-Colonel Issiaka Ouattara, known as Wattao, a former rebel leader who is now the deputy commander of the Republican Guard.
During a similar uprising in 2014, when hundreds of soldiers barricaded roads in cities across Ivory Coast demanding back pay, the government agreed a financial settlement.