The four were convicted on Tuesday of having plotted to blow themselves up in the 16 May attack in the coastal city of Casablanca.
Three were would-be suicide bombers who had survived while the fourth was a leader of the organisation responsible for the attacks.
They were among dozens of defendants in a trial of members of an obscure Moroccan group, the Salafia Jihadia. Rabat authorities claim the group is linked to al-Qaida.
The 87 defendants were handed sentences ranging from 10 years in prison to death.
Security was tight at the trial, with defendants lined up behind a bulletproof glass shield and a metal detector in the courtroom.
The trial was the first of several expected for hundreds of suspects rounded up after the attacks in Casablanca in which a dozen suicide bombers also died.
The assailants used homemade explosives stuffed into backpacks and detonated them at almost precisely the same time in five locations: a major downtown hotel along with Jewish and Spanish sites.
Investigators have said the bombers were all drafted from a shantytown on the edge of Casablanca.
The bombings stunned the North African kingdom which had prided itself on the peace that prevailed despite violence in neighbouring Algeria.