The two men, who were working for the National Geographic channel, were stabbed while shopping in a market popular with tourists, said defence minister Etienne Massard, adding that the attack appeared to be politically motivated.

“According to the first testimonies at the scene, the assailant, a 53-year-old Nigerien man, shouted ‘Allahu Akbar’ (“God is Greatest”) during the attack. He was arrested on the spot,” said Massard.

The man, who has lived in Gabon for 19 years, “in his first statements said he acted in retaliation for US attacks against Muslims and America’s recognition of Jerusalem as Israel’s capital”.

The two victims were sent to a hospital in the capital Libreville, one in a serious condition, government spokesman Alain-Claude Bilie By Nze told AFP.

The Danish foreign ministry confirmed two nationals had been “wounded in Gabon” without giving any further details.

Massard said the government was treating the attack as “an isolated act” and said an investigation had been launched.

“Following this cowardly and despicable act, the government wishes to assure the people that Gabon will not become a theatre for attacks against our way of life,” he said in a televised address.

“Everything will be done to ensure that the perpetrator and any accomplices are punished to the full extent of the law.”

Gabon, a small French-speaking former colony with 1.8 million inhabitants, has so far been spared the Islamist-inspired attacks that have taken place in some neighbouring countries.