A Moroccan judge sentenced Adel Othmani to death on Friday for plotting and carrying out an April 28 bomb attack on a cafe in Marrakesh that killed 17 people, including eight French nationals.
The blasts were the deadliest in Morocco since coordinated suicide bombings carried out by Islamist militants in the commercial capital, Casablanca, in 2003.
After the sentence was read out, female relatives of Othmani and others convicted of being his accomplices began crying and screaming, a Reuters reporter in the court room said.
The prosecution has sought the "harshest possible" sentence against Othmani and eight men accused of being his accomplices. The death penalty is allowed under Morocco's penal code but it has not been carried out since 1992. Othmani had denied the charges, which included making explosives and committing murder. His lawyers said they would lodge an appeal.
Invited earlier on Friday by the three-judge panel to make a final statement before the verdict was given, a bearded Othmani, wearing a grey New York Yankees sweatshirt, said he was the innocent victim of a political plot.
"The whole affair is baseless," he said.
"There is so much injustice in this country ... I'm failing to understand this country. Innocent people find themselves embroiled in cases like this while they are actually being used in political ploys".
The prosecution case was that Othmani, disguising himself as a guitar-carrying hippie, planted two bombs in a cafe in Jamaa el-Fna, Marrakesh's most popular tourist attraction.
The interior ministry said he showed loyalty to al Qaeda but local affiliates of the group have denied involvement.
A man convicted of being his leading accomplice, Hakim Dah, was given life in jail.
Seven others were given sentences ranging from two to four years in prison for offences that included being members of an illegal organisation, helping prepare the bombing and failing to tell police about the bomber's identity.
Attending the trial were mostly French relatives of the victims of the attack. Some carried pictures of their slain relatives while others gathered around a female translator.
Lawyers for the victims' relatives had said they wanted the suspects to be given tough sentences but that they did not want the death penalty.