French President Emmanuel Macon has changed his phone and number after reports that he was targeted with Israeli-made spyware called Pegasus.
The president's office said Mr Macron had also ordered an overhaul of security protocols.
This week, Le Monde reported that he and 14 French ministers were flagged for potential surveillance by Morocco.
Moroccan authorities have denied using Pegasus, and said the allegations were "unfounded and false".
The spyware infects iPhones and Android devices, allowing users to extract messages, photos and emails. Calls can be recorded, while microphones and cameras can be activated covertly.
It is not clear if the software was ever installed on the French president's phone. But his number was among a list of 50,000 contacts believed to be targeted by clients of NSO Group, the creator of Pegasus, since 2016.
Others reportedly include President Baram Salih of Iraq, South Africa's Cyril Ramaphosa, and the current prime ministers of Pakistan, Egypt and Morocco.
Activists, journalists, officials, politicians and business figures from dozens of countries are also featured on the list, which was leaked to the press and covered by a consortium of news organisations, together with campaign group Amnesty International.
It is not clear how many phones on the list were hacked.
Authorities in Hungary, Israel and Algeria have begun investigations into the use of Pegasus, to establish whether any crimes had taken place.
NSO Group has denied any wrongdoing. It says the software is intended for use against criminals and terrorists and is made available only to military, law enforcement and intelligence agencies from countries with good human rights records.
In recent years, the company has been accused of allowing repressive governments to hack innocent people, including those close to murdered Washington Post columnist Jamal Khashoggi.
NSO Group has denied the accusations, and said it does not routinely investigate who is targeted but has systems in place to vet the clients it works with.