ABIDJAN, Ivory Coast — Gunmen opened fire on picnickers and swimmers enjoying a perfect day at three beach resort hotels near the Ivory Coast’s largest city on Sunday, killing 16 people and leaving bodies strewn across the bloodstained sand. It was the third major attack in West Africa since November, and verified fears that the spread of terrorism across the region was far from over.

The attack, on the first sunny Sunday in weeks, took place in Grand-Bassam, a popular palm tree-lined getaway for Ivorians and foreigners. Fourteen civilians and two members of the country’s special forces were killed, as well as six gunmen, according to a spokeswoman for the president.

The authorities in Ivory Coast appealed for calm.

“The situation is under control,” President Alassane Ouattara told reporters on a visit to the scene of the shootings.

The North African affiliate of Al Qaeda, Al Qaeda in the Islamic Maghreb, claimed responsibility for the attack in a statement released on Sunday evening that praised three “knights” who had carried it out. There was no immediate explanation for the discrepancy in the number of attackers.