The Mexican government has deployed sophisticated software to spy on journalists, activists and anti-graft groups as they worked to highlight some of the country's most notorious cases of crime, corruption and abuse of authority.

Targets received SMS messages with links which appeared legitimate but led to false sites and the installation of malware on their mobile phones, according to an investigation by the press freedom organization Article 19 and Citizen Lab at the University of Toronto.

The malware recorded keystrokes and compromised contact lists. It was used against targets ranging from activists pushing for soda taxes to journalists reporting on alleged army atrocities and the lawyers representing the families of the 43 teacher trainees abducted by police.

When unflattering stories hit the headlines, researchers say SMS messages carrying malware links would arrive on the targets' smartphones. Once activated, "it's game over," said John Scott Railton, a senior researcher at Citizen Lab.

The spyware, produced by Israel's NSO Group, is only sold to governments, prompting researchers to conclude that the spying was state-sponsored -- though they cautioned it had "no conclusive evidence attributing these messages to specific government agencies in Mexico."

The scandal prompted outrage in Mexico, where attacks on the press and activists routinely end in impunity and where six journalists have been murdered in 2017.

"Espionage in Mexico has become an effective mechanism for intimidating human rights defenders, activists and journalists," said a statement from some of the alleged victims. "It makes it possible to control the flow of information as well as (allowing) abuses of power."

The spying marked the latest escalation in a tense relationship between the government of Enrique Peña Nieto and his Institutional Revolutionary party (PRI) and Mexican civil society.

Peña Nieto has promoted Mexico internationally as progressive and reformist and his actively denounced a deterioration of democracy in Venezuela. But critics question his record at home, and point to the espionage against activists and journalists exposing his administration's worst excesses -- such as the Casa Blanca scandal, in which the first lady purchased a mansion from a crony contractor.

"They have authoritarian tendencies," said Manuel Molano, deputy director of the Mexican Institute for Competitiveness (IMCO), a thinktank, who received the malware links.

IMCO has championed the creation of an anti-corruption system and an initiative to make politicians' patrimonies public. Its director, Juan Pardinas, told New York Times his wife received erroneous messages alleging an extramarital affair and stories of armed individuals outside their home as an enticement to click the included link.

Journalist Carmen Aristegui -- whose team broke the "Casa Blanca" scandal -- said she received fake emails purporting to be from the US embassy in Mexico. Her 16-year-old son Emilio was also targeted, prompting her to ask: "What was the Peña Nieto government going to do with information on a young student?"

Gerardo Priego, a former politician with the right-leaning National Action party, said spying is nothing new in Mexico.

Politicians' embarrassing private conversations leak constantly, while many in politics and election campaigns keep communications via mobile phones and email to a minimum, knowing someone is likely listening in. The practice is now spreading to activists and journalists, he said, as movements in favour of human rights and stopping graft gain ground.

"Often there are more ‘dangerous' people to the system of politics-as-usual among the ‘rebellious citizenry' than in politics itself," Priego said. "Party members are still lining up to feast on this giant cake made out of power and money (so) they're more 'dangerous' for the government and politicians."