Morocco's king has promised an investigation after his pardoning of a Spanish paedophile sparked violent protests and that there will now be an investigation into the decision.

In a statement late on Saturday, King Mohamed VI said he did not know the gravity of the man's offending when the decree was issued at the behest of the Spanish king, Juan Carlos.

"The king has ordered a thorough investigation to find out the responsibilities and failures that led to the regrettable release ... and to impose the necessary punishments," the palace said in a statement carried by state news agency MAP.

"The king had not been informed at any time of the nature of the crimes perpetrated by that person," the statement said, adding the king would never have agreed to the release of Daniel Galvan Fina if he had known "of the atrocity of the monstrous crimes of which he was found guilty".

The paedophile was convicted 18 months ago in Kenitra, near the capital Rabat, of raping children aged 4 to 15. Fina, who was serving a 30-year sentence, was among 48 jailed Spaniards who were pardoned by King Mohamed VI on Tuesday at the request of Spain's King Juan Carlos, who visited Morocco last month.

Late on Friday, baton-wielding police broke up a protest in Rabat by hundreds outraged by the pardon. In running clashes, the police clubbed demonstrators to prevent them from gathering in front of the Moroccan parliament in the centre of the capital Rabat, injuring several people including journalists.

The Justice Ministry said in a statement on Friday the pardons had been issued based on Morocco's national interests and its friendly relations with Spain.

The king often pardons prisoners on special occasions, such as Throne Day last Tuesday, but the decision to release the Spaniards at the request of the monarch of a former colonial power riled many Moroccans.