MEXICO CITY — The Mexican government said Wednesday that it was opening a criminal investigation to determine whether the nation’s most prominent journalists, human rights defenders and anticorruption activists were subjected to illegal government surveillance.

The announcement followed an article by The New York Times that detailed a sweeping operation using advanced spyware to infiltrate a target’s smartphone, turning it into a power surveillance tool.

The software, known as Pegasus, was sold to the Mexican government by an Israeli cyberarms company on the condition that it be used for the sole purpose of investigating criminals and terrorists. But the spyware was deployed against some of Mexico’s most influential reporters and activists, including a highly respected academic pushing for anticorruption legislation, two of Mexico’s most famous journalists and lawyers looking into the case of 43 students who mysteriously disappeared after clashing with the police.

Forensic analysts at digital rights groups in Mexico and at the Citizen Lab at the University of Toronto’s Munk School, found that the surveillance operation had also swept up an American citizen, as well as the family members of some government critics, including a teenage boy living in the United States.