The three suspects were all Moroccans, the official news agency quoted the Interior Ministry as saying. Most of the bomb victims were foreign holidaymakers, including eight French people.
The ministry said the chief suspect was “well-versed in jihadi ideology and shows loyalty to al Qaeda”.
It said the suspect had previously tried to fight alongside Islamist militants in Russia’s turbulent Chechnya republic and in Iraq.
It said he dressed like a tourist to plant two remote-detonated devices, which then tore through a cafe overlooking Marrakesh’s Jemaa el-Fna square, a spot that is often packed with tourists.
It was the first such attack in Morocco since 2003, when suicide bombings in the commercial capital, Casablanca, killed more than 45 people.