Spain's fragile coalition government was on the defensive Tuesday over its announcement that the mobile phones of the premier and defence minister were tapped using Pegasus spyware.

Felix Bolanos, a cabinet minister, told a news conference on Monday that the phones of Socialist Prime Minister Pedro Sanchez and Defence Minister Margarita Robles were hacked last year using the spyware made by Israel's NSO Group.

The disclosure followed accusations from Catalonia's regional government that Spain's intelligence services used Pegasus to hack the mobile phone of dozens of separatist politicians.

According to Canadian cybersecurity watchdog Citizen Lab, the phones of over 60 people linked to the Catalan separatist movement had been targets of spyware after a failed independence bid in 2017.

The allegations have poisoned the central government's relations with Catalan separatist party, ERC.

Sanchez's minority government relies on the ERC to pass legislation and remain in power until the next general election due at the end of 2023.

The ERC and the conservative opposition on Tuesday questioned the timing of the disclosure that Sanchez's phone had been hacked.

The government has "suddenly gone from being the alleged perpetrator to victim. It has no credibility," said Gabriel Rufian, ERC's bench leader in parliament.

"There are a ton of unanswered questions. The explanations given were pathetic," he told a news conference, adding the affair could "put an end to the legislature".

- Bid to 'earn sympathy' -

Esteban Gonzalez Pons, a senior official with the main opposition conservative Popular Party (PP), accused the government of "announcing a national security breach with a one-year delay to earn sympathy" from the Catalans.

During an interview with news radio Ser on Tuesday, Bolanos said the government was only informed of the phone hacking "this weekend".

Bolanos said on Monday the phone hacking was an "external attack", adding the details of the incidents in May and June 2021 had been sent to Spain's high court for investigation.

Asked during the radio interview if Morocco was responsible, he said it was important "not to make assumptions".

"We don't know who it is," he added.

At the time of the hacking, Madrid and Rabat were engulfed in a diplomatic crisis sparked by Spain's decision to host a Western Sahara independence leader for medical treatment.

An investigation published last year by 17 media organisations accused Morocco of using Pegasus, which infiltrates mobile phones to extract data or activate a camera or microphone to spy on their owners. Rabat denies the allegations.

NSO Group claims the software is only sold to government agencies to target criminals and terrorists, with the green light of Israeli authorities.

The company has been criticised by global rights groups for violating users' privacy around the world and it faces lawsuits from major tech firms such as Apple and Microsoft.