Mutinying soldiers in Ivory Coast's second largest city, Bouake, opened fire on a local official's house where the defence minister was staying shortly after he appeared to have brokered a deal to end a two-day revolt.

Defence minister Alain-Richard Donwahi was trapped inside by the shooting late on Saturday, unable to head back to the commercial capital, Abidjan.

Al Jazeera's Ahmed Idris said a source reported from inside the house of a local official in Bouake - where Donwahi was staying with other government representatives - that it had been surrounded by soldiers and fired upon.

"He said the situation is tense and the soldiers say they're not moving an inch until all their demands are met," said Idris.

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, the mayor of Bouake and other local officials, as well as journalists, were trapped inside the residence.

A crowd of angry soldiers massed outside the house and a Reuters news agency reporter said he heard some loudly shouting that they wanted their bonuses paid immediately, not next week.

"It just shows that the situation is unpredictable. It's a very confused situation right now," Kamissa Camara from the National Endowment for Democracy told Al Jazeera. "It is quite worrying and we don't know where it's going to go.

"The worst-case scenario could be the military wanting to remove President Ouattara. It's all speculation at this point."

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.

READ MORE: Gunfire rocks Bouake army camp after troops pay tribute

Ivory Coast, French-speaking and 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, a 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 upon a financial settlement.