All four defendants had been convicted at a trial in July, but the fourth defendant was originally sentenced to life imprisonment for the murder of the two women, killed while hiking in the High Atlas mountains.
Those sentenced to death included ringleader Abdessamad Ejjoud, a street vendor and underground imam, who had confessed to orchestrating the attack with two other radicalised Moroccans.
They had admitted killing 24-year-old Danish student Louisa Vesterager Jespersen and 28-year-old Norwegian Maren Ueland in murders that shocked the North African country.
Although the death penalty remains legal in Morocco, there have been no executions there since 1993 because of a moratorium, and the issue of capital punishment is a matter of political debate.
The court in Sale, near Rabat, confirmed jail sentences of between five and 30 years against 19 other men, but increased the jail sentence of another man from 15 to 20 years.
The court also confirmed an order for the three men who carried out the killings and their accomplices to pay two million dirhams (190,000 euros) in compensation to Ueland's family.
But it refused a request from the Jespersen family for 10 million dirhams in compensation from the Moroccan state for its “moral responsibility”.