A Moroccan court on Monday sentenced journalist and human rights activist Omar Radi to six years in jail on charges of espionage and rape, offences which he has denied.
Radi's trial opened in June last year, just days after rights group Amnesty International charged that Moroccan authorities had planted Israel-made Pegasus spyware on his cellphone.
Rabat denied the report at the time, and on Monday the authorities "categorically rejected" using Israeli spyware to monitor critics at home and abroad.
Radi, 35, is a known vocal critic of the authorities and has been detained since July 2020.
His arrest and detention sparked protests by rights activists, intellectuals and politicians at home and abroad.
He faced charges of rape and "undermining the internal security of the state" in two separate cases investigated separately but judged together.
Radi was also accused of having received "foreign funds" in exchange for providing "intelligence" information to a third party.
On Monday Amnesty in a statement labelled the proceedings "flawed" and "not justice", and called for "a fair retrial in line with international standards".
At a previous hearing in June, the judge questioned Radi about text messages he had exchanged with a Dutch diplomat in 2018.
Radi has protested his innocence throughout, and last month told the court the case against him was void and "did not justify my imprisonment for nearly a year".
He said he was the victim of people "who consider themselves above the law", and rejected both charges of rape and espionage.
"Where is the crime in a journalist meeting and exchanging (views) with an official from a foreign country?" he asked.
Monday's ruling came as Morocco said it "never acquired computer software to infiltrate communication devices".
A government statement denied that Rabat had "infiltrated the phones of several national and international public figures and heads of international organisations through computer software".
A joint investigation by several Western media outlets said on Sunday that activists, journalists, businessmen and politicians around the world had been spied on using the software developed by Israeli firm NSO.
The media outlets, including The Washington Post, The Guardian and Le Monde, drew links between NSO Group and a list of tens of thousands of smartphone numbers.
Many numbers on the list were clustered in 10 countries, among them Morocco.
Rabat on Monday expressed its "great astonishment" at the reports, calling them "false allegations devoid of any foundation".
Also on Monday, the same court in Casablanca handed six months in jail to another journalist, Imad Stitou, 32, who was said to have been present with Radi when he allegedly raped a woman.
Radi had said the sex was consensual.
Radi's is the latest in a series of harsh sentences passed against journalists in the North African kingdom, and also in neighbouring Algeria.
Authorities in both countries have detained and tried journalists on charges ranging from harming national interests to sexual assault.
Last week the United States criticised its ally Morocco's rights record, after it gave a five-year jail term to another journalist, Soulaimane Raissouni.
Media watchdog Reporters Without Borders has ranked Morocco 136 out of 180 countries in its 2021 World Press Freedom Index, and Algeria at 146.
Last year a Human Rights Watch report sounded the alarm at the erosion of press freedoms in the two Maghreb states.
"Algerian and Moroccan authorities might compete in many domains, but when it comes to disliking bold journalism and commentary, they agree," HRW's Eric Goldstein said in the report.
"Morocco's modus operandi is to file a host of specific criminal charges, while the Algerian authorities prefer vaguely defined penal code offences," he said.