A group of soldiers was arrested in Niger after an "attempted coup" early on Wednesday, a security source said after gunfire broke out in the capital Niamey. The situation in the West African country, is now "under control", said the source, speaking on condition of anonymity. Residents reported hearing bursts of gunfire overnight near the presidential villa, only a couple of days before Mohamed Bazoum is scheduled to take the helm of the country. "There were some arrests among a few members of the army who are behind this attempted coup," the source said. "The Presidential Guard retaliated, preventing this group of soldiers from approaching the presidential palace." A resident of Niamey's Plateau district, which includes the president's official residence and offices, told AFP that the gunfire lasted nearly a quarter of an hour. "It was around 3am, we heard shots from heavy and light weapons and it lasted 15 minutes before stopping, followed by shots from light weapons." "The gunfire lasted about 20 minutes," another resident said. A third resident spoke of "intense shooting, with heavy and light weapons". Local news media reported that calm had returned by about 4am. In videos posted online sporadic bursts of gunfire could be heard in the pitch dark. It was not yet possible to independently verify the location and time. The alleged coup comes ahead of Mr Bazoum's scheduled inauguration on Friday – the first elected transition in Niger since independence from France in 1960. Mr Bazoum is a former interior minister and the right-hand man of departing president Mahamadou Issoufou, who is stepping down voluntarily after two five-year terms. Mr Bazoum's victory in the second round of the election on February 2 was confirmed by the constitutional court this month. The results were contested by Mr Bazoum's rival, former president Mahamane Ousmane, who claimed he was the real winner. Mr Ousmane had called for "peaceful marches" across the country, but a planned opposition protest on Wednesday in Niamey was banned a day earlier by authorities. Niger is the poorest country in the world, according to the benchmark of the UN's 189-nation Human Development Index. It has suffered four coups, most recently a February 2010 putsch that toppled then president Mamadou Tandja. The Sahel country has also recently been struck by repeated extremist attacks as violence has spilled over from neighbouring Mali and Nigeria.