A court in Rabat has sentenced 15 people to 20 years in prison for plotting terrorist attacks while 26 other defendants were given jail terms ranging from two to 15 years.
Three of the 45 defendants in the so-called "Agadir terrorist cell" were acquitted and another one was fined 3000 dirhams (33 euros), a judicial source said on Saturday.
The defendants, all from the southern city of Agadir, were accused of conspiracy to commit terrorist acts, offering lodging to a criminal, failure to denounce and attempt to collect funds to commit a terrorist attack.
Prosecutors had requested heavy sentences for 12 of the defendants but said 23 others were considered less dangerous.
The prosecution claimed the Agadir cell was part of the banned armed group Salafist Jihad, which is blamed for the 16 May attacks in Casablanca that killed 45 people.
Defence lawyers had argued that their clients were innocent and pointed to the lack of evidence against them.
In August, a Casablanca court sentenced four Islamist activists to death and dozens more to heavy jail terms for the May attacks.
Twelve of the 45 killed in the attack targeting a Spanish restaurant, the Belgian consulate, a Jewish community centre, a cemetery and a hotel, were believed to be the assailants themselves.