Three prison guards have been killed and three wounded in Niger's capital Niamey during what government officials said was a failed escape attempt by fighters convicted of terrorism charges.
Saturday's gun battle in the city centre came just a week after al Qaeda-linked groups raided a uranium mine and an army barracks, raising fears that the conflict in neighbouring Mali could spread to other West African states.
Local residents said shooting began at around 3pm local time (1500 GMT) near the entrance to the prison, which houses over 600 inmates including Nigerian Boko Haram fighters and members of other armed Muslim groups.
The attack was carried out by "four individuals detained at the civilian prison of Niamey and prosecuted for terrorism", Marou Amadou, justice minister, told AFP news agency.
Three of the inmates were overcome, he said, while not confirming an earlier assertion that the fourth inmate was still in the prison grounds.
Amadou said an investigation has been launched to determine how they obtained the weapons. They also seized a weapon from one of the guards.
Official would not give further details on the inmates' identities or explain how they had come to be armed.
Officials had said earlier that security forces were looking for part of a group who had attacked the prison, believed to have fled aboard a lorry, while other armed men were thought to still be hiding out in houses near the prison.
Local witnesses reported a number of civilians had also been lightly wounded and said they saw several men, their heads covered in turbans, open fire on the guards. They also said they heard a loud explosion.
A senior official with the National Guard, which provides the guards for Niger's prisons, said the three escapees included two Boko Haram fighters and a Sudanese arms dealer, who had been arrested separately over the last two years.
Witnesses said gendarmes had rushed to the prison to reinforce guards who remained under fire for around 45 minutes.
Local residents fled on foot as police blocked off roads leading to the prison, allowing only ambulances into the area.
A prison official said guards would only take a head count on Sunday morning, believing it was too dangerous to do so at night.
Niger has emerged as a firm ally of France and the US in the fight against al Qaeda-linked groups in the arid Sahel region.
Its army has deployed 650 troops in neighbouring Mali to take part in a French-led war on armed Muslim groups who seized the northern two-thirds of the country last year.
The government has sought to shut its porous desert borders to the armed groups that are thought to have shifted their bases to southern Libya, and has allowed the US to establish a drone base on its territory.
Niger's soldiers are also participating in joint operations with neighbours Nigeria against that country's Boko Haram fighters, whose armed insurgency and bombing campaign has pushed to government to launch a major military offensive.
Mokhtar Belmokhtar, a veteran of al Qaeda's North African operations, claimed that his fighters were behind attacks on an army barracks in Agadez and a mine operated by French company Areva in the remote town of Arlit on May 23.
He said the raids, a joint operation with the MUJWA armed group which killed 24 soldiers and one civilian, had been launched in retaliation for Niger's role in a French-led war on armed groups in neighbouring Mali.