King Mohamed VI of Morocco on Sunday revoked a pardon granted to a Spanish serial paedophile whose release sparked angry protests in the kingdom, a palace statement said.
The king "has decided to withdraw the pardon previously accorded to Daniel Galvan Vina", said the text of the statement, published by the official MAP news agency.
It said the "exceptional" decision was taken because of the "gravity of the crimes committed and out of respect for the victims' rights".
Although several media reports have said Vina has left the country, the agency said the justice minister would discuss with Madrid "the next step after the pardon's revocation".
This "opens the way for Rabat to request the paedophile serves in a Spanish jail" the 28 years remaining of his sentence, Spain's ambassador to Morocco, Alberto Navarro, told Spanish daily El Pais.
The king's announcement came shortly before a demonstration against the pardon, after baton-wielding police dispersed protests on Friday.
Hundreds gathered in Kenitra, north of the capital, where Vina was imprisoned, according to an AFP reporter on the scene.
The protest took place under a heavy police presence but passed off peacefully. Demonstrators expressed satisfaction at the king's actions but continued to press for explanations as to how the initial pardon could have occurred.
Sit-ins planned for Casablanca on Tuesday and Rabat on Wednesday were still due to go ahead.
Vina, said to be in his 60s, was pardoned by the king and freed last Tuesday from jail. He had been sentenced in September 2011 to 30 years in prison.
Convicted of raping 11 children aged between four and 15, Vina was among 48 Spanish prisoners released in response to a request from Spanish King Juan Carlos, who visited Morocco in mid-July, the justice ministry said.
In Spain, the opposition socialist party demanded explanations from the government.
Earlier, the palace said in a statement carried on MAP that the king had been unaware of the nature of the man's crimes and had ordered a probe into his release.
The investigation should "determine the responsibilities and the failures that led to this regrettable release", the statement said.
"The king was never informed -- in any way or at any time -- of the seriousness of the abject crimes of which the person concerned was convicted," the palace added.
"It is clear that the sovereign would never have consented" to his release, given the "monstrous crimes" he committed, the statement concluded.
The pardon sparked outrage in the north African country, which has seen several high-profile paedophile arrests in recent months.
Protesters slammed the pardon as "an international shame" with one demonstrator saying the state "defends the rape of Moroccan children".
On June 20, police arrested a British suspected paedophile after local residents overheard screams from a six-year-old girl he allegedly abducted.
And in May, a Casablanca court jailed a 60-year-old Frenchman for 12 years after convicting him of paedophilia.