Three men were convicted of terrorism and sentenced to death by a Moroccan court for the brutal slaying of two Scandinavian women hiking in the Atlas Mountains.
A fourth suspect who fled the scene was given life in prison.
After several hours of deliberation, the court handed 19 accomplices jail terms ranging from five to 30 years. All have 10 days to appeal.
Maren Ueland, 28, from Norway, and Louisa Vesterager Jespersen, 24, from Denmark, were fatally stabbed in December. The slayings were recorded on video and posted online.
None of the 23 reacted as the sentences were read out Thursday, but their families rushed out of the crowded courtroom crying.
The men claimed allegiance to the Islamic State group.
All 23 addressed the court before the verdicts, most begging for leniency.
The main defendants, who asked Allah for forgiveness, were carpenters Jounes Ouzayed and Rashid Afatti, and street merchant Abdessamad Al Joud. They were sentenced to death.
The man who fled the scene is Khaiali Abderahman, who got life.
Morocco only rarely carries out death sentences. The last execution was in 1993 of Mustapha Tabet, a once-powerful Casablanca police commissioner, convicted of raping and abusing hundreds of victims.
In closing arguments in June, the prosecutor asked the court to sentence the top suspects to death, and described the three main defendants as 'human beasts.'
A Swiss-Spanish convert to Islam, Kevin Zoller, who had pleaded innocent, received a 20-year sentence. Prosecutors said he had links to the men who orchestrated the women's killings and direct contact with IS members in Syria via the encrypted messaging service Telegram.
Another Swiss man was sentenced in April to 10 years in prison, convicted on charges including 'deliberately helping perpetrators of terrorist acts' and training terrorists, the state-run news agency MAP said at the time.
The lawyer for Vesterager's family said he was '100% satisfied' with the verdicts. Khalid El Fataoui noted that Louisa Vesterager's mother had asked the court in a letter at an earlier hearing this month to sentence the killers to death.
'We obtained what she asked for.'
The court also ordered the four main defendants to pay the equivalent of $300,000 in damages to the family of the Norwegian victim, but refused a demand from the Danish victim's family for the Moroccan state to pay damages.
El Fataoui said he would appeal.
© Nine Digital Pty Ltd 2019