Benin's president has appeared on television to reassure citizens of the West African nation that the situation was now totally under control following an attempted coup earlier in the day.

I would like to commend the sense of duty demonstrated by our army and its leaders, who have remained... loyal to the nation, Patrice Talon said, looking calm during the live evening broadcast.

The government said it had thwarted the mutiny hours after a group of soldiers declared a takeover on national television.

Later in the afternoon, huge explosions were heard in Cotonou, Benin's largest city and seat of government. They were thought to have been the result of an air strike.

Prior to the explosions, flight-tracking data showed that three aircraft had entered Benin's airspace from neighbouring Nigeria before returning home.

A spokesman for Nigeria's president later confirmed that its fighter jets had gone in to take over the airspace to help dislodge the coup plotters from the national TV and a military camp where they had regrouped.

There have been a series of coups in West Africa before Sunday's thwarted attempt in Benin, heightening fears that the security of the region could worsen.

Benin, a former French colony, has been regarded as one of Africa's more stable democracies. But Talon has faced accusations of suppressing criticism of his policies.

The nation is one of the continent's largest cotton producers, but ranks among the world's poorest countries.

Nigeria, Benin's large neighbour to the east, has described the coup attempt as a direct assault on democracy.

The 67-year-old president said in his address that loyalist forces had cleared the last pockets of resistance held by the mutineers.

This commitment and mobilisation enabled us to defeat these opportunists and avert disaster for our country. This treachery will not go unpunished, he added.

I would like to reassure you that the situation is completely under control and therefore invite you to go about your business peacefully this evening.

It is not clear if there have been casualties, but the president expressed his condolences to the victims of this senseless adventure, as well as to those still being held by fleeing mutineers.

Earlier, government spokesperson Wilfried Leandre Houngbedji told news agency Reuters that 14 people had been arrested in connection with the attempted coup.

A journalist in Benin told the BBC that, of those reportedly arrested, 12 are believed to have stormed the offices of the national TV station - including a soldier who had previously been sacked.

Eyewitnesses told the BBC gunfire was heard near the presidential residence early on Sunday morning, as a group of soldiers announced on national TV that they were suspending the constitution.

They also said some journalists working for the state broadcaster had been held hostage for a few hours.

The French and Russian embassies urged their citizens to remain indoors, while the US embassy's advice was to stay away from Cotonou, especially the area around the presidential compound.

The rebel soldiers, led by Lt Col Pascal Tigri, justified their actions by criticising Talon's management of the country, complaining first about his handling of the continuing deterioration of the security situation in northern Benin.

In recent years, West Africa has also seen coups in Burkina Faso, Guinea, Mali and Niger, prompting concerns about the region's stability.

News of the attempted takeover in Benin was hailed by several pro-Russian social media accounts. Ecowas and the African Union (AU) have both condemned the coup attempt.

A contingent from Ecowas's standby force is to be deployed to preserve the constitutional order and the territorial integrity of the Republic of Benin, the regional bloc has said in a statement.

AU Commission chair Mahmoud Ali Yousouf reiterated the pan-African organisation's zero tolerance stance toward any unconstitutional change of government, regardless of context or justification.