Most of the men who attacked towns in Ivory Coast over the weekend are from neighbouring Mali and Burkina Faso, an Ivory Coast military prosecutor says.
The gunmen killed five policemen in Abidjan
The men did not say who had sent them to attack the main city, Abidjan and Agboville 70km north, said Ange Kessi.
President Laurent Gbagbo has accused both neighbours of backing rebels who control northern Ivory Coast.
The attacks threaten a fragile peace process, which is supposed to lead to elections in October.
Members of Mr Gbagbo's Ivorian Popular Front (FPI) party have accused the New Forces rebels of being behind the attacks, which the rebels have denied.
FPI chief Pascal Affi Nguessan condemned the 10,000 French and United Nations peacekeepers in Ivory Coast for their "passivity and complicity" in the "repeated barbaric killings".
Following the attacks, pro-Gbagbo militants have attacked journalists and members of opposition parties in Abidjan.
The army has now retaken control of Agboville.
Seventeen of the assailants were killed, along with seven members of the security forces, the army says.
Eleven alleged assailants were paraded before journalists at a military prison in the main city, Abidjan.
After killing five policemen at an Abidjan police station, the attackers retreated some 70km to Agboville, where they took control of government buildings and released prisoners from the town's jail.
The Muslim Djoula community lives in northern Ivory Coast, Mali and Burkina Faso and pro-Gbagbo groups from the Christian and animist south see them as rebel sympathisers.
Almost a quarter of Ivory Coast's population are said to be immigrants from Mali and Burkina Faso.
Ivory Coast's neighbours have denied backing the rebels.
Under a South Africa-brokered peace deal, the rebels and pro-Gbagbo militias are supposed to be disarming, ahead of election in October.