The mobile phones of the Spanish prime minister and defence minister were infected last year with Pegasus spyware that is only available to government agencies in an unauthorised operation, officials have said.

Prime Minister Pedro Sanchez's mobile phone was breached twice in May 2021, and defence minister Margarita Robles' device was targeted once the following month, presidency minister Felix Bolanos said at a hastily convened news conference.

He said the breaches resulted in a significant amount of data being obtained, and that reports detailing the breaches have been transferred to Spain's National Court for further investigation.

"We have no doubt that this is an illicit, unauthorised intervention," Mr Bolanos said.

"It comes from outside state organisms and it didn't have judicial authorisation."

Spain's Socialist-led government is under pressure to explain why the mobile phones of dozens of people connected to the separatist movement in the north-eastern Catalonia region were infected with Pegasus between 2017 and 2020, according to Citizen Lab, a cybersecurity group of experts affiliated with the University of Toronto.

The revelations involve at least 65 people, including elected officials, lawyers and activists, targeted with the software of two Israeli companies, Candiru and NSO Group, the developer of Pegasus.

The spyware silently infiltrates phones or other devices to harvest data and potentially spy on their owners.

The regional Catalan government has accused Spain's National Intelligence Centre (CNI) of spying on separatists, and declared that relations with national authorities were "on hold" until full explanations are offered and those responsible are punished.

The conservative Popular Party (PP) was in office in 2017, when Catalan separatists declared independence following an unauthorised referendum, although no further action was taken to execute the declaration.

The PP remained in power until mid-2018, when it was ousted by Mr Sanchez in a parliamentary vote.

ERC, the main political party in Catalonia and a crucial ally of the government, has called for the resignation of Ms Robles, the defence minister.

But the spying scandal has left them exposed to the pressure of more radical separatists, who are calling on ending the support for Mr Sanchez's left-to-centre coalition in the national parliament.

The central government has attempted to temper their concerns with pledges of full transparency, announcements of plans for an internal probe by the country's intelligence agency, and a separate investigation by Spain's ombudsman.

A special parliamentary commission on state secrets has also been established and the head of the CNI is expected to be questioned by legislators later this week, although discussions around state security issues are not meant to be publicised.