Rabat: Moroccan authorities believe four suspects in the killing of two Scandinavian tourists had travelled to the Atlas Mountains intent on committing a crime but had not selected a target in advance.

They were apparently acting on their own initiative, even though they had just pledged allegiance to Islamic State, an official said on Sunday.

Pictures of Maren Ueland and Louisa Vesterager Jespersen are displayed during a candlelight vigil outside the Norwegian embassy in Rabat. Credit:AP

Boubker Sabik, spokesman for the Moroccan security and domestic intelligence services, also said the arrest of nine more people in the case had foiled a terror plot.

Louisa Vesterager Jespersen, 24, from Denmark, and Maren Ueland, 28, from Norway were found dead early on Monday near the village of Imlil on a route to Toubkal, North Africa's highest peak and a popular hiking and trekking destination.