Morocco's government on Wednesday threatened legal action against anyone accusing it of using the Israeli spyware programme Pegasus, and deplored what it called a "false, massive, malicious media campaign".
A government statement "categorically denied the false and unfounded allegations" that the North African country's intelligence services had used the software.
News outlets had reported on Sunday that the software, developed by Israeli firm NSO Group, had been used by governments to spy on activists, journalists, lawyers and politicians around the world.
The bombshell claims were based on a leaked document containing 50,000 numbers of people identified as potential targets via Pegasus between 2016 and June 2021.
Numbers from 10 countries -- Azerbaijan, Bahrain, Hungary, India, Kazakhstan, Mexico, Morocco, Rwanda, Saudi Arabia and the United Arab Emirates -- figured particularly often on the list.
On Monday, Morocco said it had "never acquired computer software to infiltrate communication devices".
A day later, Radio France reported that the Moroccan king was on the list of 50,000 numbers, which also included "a large number" of Moroccan royals.
Wednesday's government statement said Rabat would "opt for a judicial process, in Morocco and internationally, against any party taking up these spurious allegations".
Pegasus is a highly invasive tool that can switch on a target's phone camera and microphone, as well as access data on the device, effectively turning a phone into a pocket spy.
In some cases, the software can be installed without the need to trick a user into initiating a download.
French President Emmanuel Macron and members of his government are among the potential targets for the spyware supplied to several governments, the Forbidden Stories group that leaked the list said on Tuesday.
Forbidden Stories, a Paris-based media nonprofit, and Amnesty International got access to the leaked numbers, which they then shared with media organisations including The Washington Post, The Guardian and Le Monde.
NSO has denied selling the software to authoritarian governments for the purposes of spying on dissenters, and insists it is only intended for use as a counter-terror and anti-crime tool.