Three men who claimed allegiance to ISIS after brutally killing two Scandinavian women hiking in the Atlas Mountains in Morocco have been sentenced to death.

The men – Jounes Ouzayed, Rashid Afatti, and Abdessaman Al Joud – are the three main defendants accused of killing and beheading Maren Ueland, 28, of Norway, and Louisa Vesterager Jespersen, 24, from Denmark, in December. The slayings were recorded on video and shared on social media by ISIS supporters.

On Wednesday, a court in Morocco convicted them on terror charges. A fourth suspect, Kahiali Abderahman, who fled the scene, was given life in prison.

MOTHER OF MURDERED SCANDINAVIAN TOURIST WAS SENT GRAPHIC IMAGES OF HER DAUGHTER'S KILLING: REPORT

The Moroccan court also handed 19 accomplices jail terms ranging from five to 30 years.

The 23 men addressed the court ahead of the verdicts, most begging for leniency. The main defendants asked Allah for forgiveness.

BACKPACKERS 'BEHEADED' IN MOROCCO MOUNTAINS WERE 'EXECUTED BY TERRORISTS,' SECURITY SOURCES SAY

The bodies of the two women – roommate at Norway’s Bo University – were found on December 17 in an isolated area near Mount Toubkal, Morocco’s highest peak, and a popular hiking destination. The two women were on a Christmas camping trip and were studying to become tour guides.

During the trial, it emerged that Al Joud, 25, Quzayed, 27, beheaded the two women, while Afatti, 33, filmed the slayings on his cell phone. Earlier this year, Al Joud admitted in court to killed one of the two women.

“The most just thing would be to give these beasts the death penalty they deserve,” Helle Petersen, Jaspersen’s mother, said in a letter that was read out in court last week, the BBC reported.

If the executions against the three men go ahead, they will be the first in the northern African nation since 1993.

DENMARK CHARGES 14 PEOPLE - INCLUDING 13-YEAR-OLD - FOR SHARING VIDEO OF BACKPACKER BEHEADING

While the three men have said they are ISIS supporters, the terror group has not said it was behind the killings.

Morocco’s anti-terror chief told AFP that the group was inspired by ISIS, but had no contact with militants in combat zones.

Danish authorities have said the video that circulated of the slayings was genuine and have charged 14 people - including a 13-year-old - with sharing it on social media. Six of the accused were between the ages of 13 and 18, police said.

CLICK HERE TO GET THE FOX NEWS APP

In his 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."

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."

Fox News' Greg Norman and Robert Gearty and the Associated Press contributed to this report.