MEXICO CITY — Even as Mexico’s president, Enrique Peña Nieto, acknowledged for the first time on Thursday that his government had purchased sophisticated software that has been used to spy on its fiercest critics, he also threatened to investigate those who “have raised false accusations” against his administration.

That group would presumably include the victims themselves, including journalists and human rights lawyers, as well as the various media organizations that have reported on the spying.

At a press event, Mr. Peña Nieto acknowledged for the first time that his government had bought the sophisticated Israeli-made spyware, called Pegasus, but denied that it had ordered the surveillance. He promised an investigation into the misuse of the spyware. He then added: “And I hope, under the law, it can be applied against those that have raised false accusations against the government.”

The immediate response, in particular of victims of the hacking attempts, was shock.

“This not the expected behavior of the head of state of a young democracy,” said Juan Pardinas, the head of the Mexican Institute for Competitiveness, who was the victim of a hacking attempt. “This is the statement of an apprentice of Vladimir Putin.”