Saturday's attack on the Danes, who were in the west African state filming for National Geographic, was “premeditated,” Libreville prosecutor Steeve Ndong Essame Ndong said, adding that the man had lived in Gabon for 19 years.
He said the 53-year-old, who shouted “Allahu akbar” during the attack, came to Libreville on Thursday “with the aim of committing this cowardly act 'against whites'”, adding that it was not clear if the attacker was acting alone or for a group.
The man said in his first statements that he “acted in retaliation for US attacks against Muslims and America's recognition of Jerusalem as Israel's capital,” Defence Minister Etienne Massard said.
The Danes were stabbed while shopping for souvenirs in a popular tourist market in the heart of the capital.
The man sustained severe injuries in the back and neck but his life is not in danger.
Police have made several arrests and 38 West Africans are in custody.
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.