A French intelligence agent sent a text message by mistake to the mobile phone of a jihadist, inadvertently warning him that he was under surveillance and undermining an investigation, it emerged on Friday.

The target of the probe, described as an “Islamist preacher” based in the Paris area, immediately understood that his phone was being tapped and his movements monitored.

He called the agent to complain and warned his contacts that they were under surveillance. As a result, separate investigations by two different intelligence services came to nothing, M6 television reported.

“It was undoubtedly the worst mistake the agent ever made,” M6 commented. Interior ministry sources confirmed the report.

The intelligence officer had meant to send the text to a colleague last Saturday. It contained information about the Islamist and the progress of the investigation.

It was only when the Islamist decided to have some fun at the officer’s expense and phoned him minutes after he sent the text that he realised what he had done.

The two agencies involved, the Central Territorial Intelligence Service and the General Directorate for Internal Security, were furious over the mishap.

The incident came as France remains under a state of emergency declared after the 2015 Paris terrorist attacks.

Some of the emergency measures, notably beefed up police powers, are to be made permanent under a bill that has been approved by the lower house of parliament, the National Assembly.

Despite criticism that the legislation risks curtailing civil liberties because it codifies measures such as stop and seizure and house arrest without judicial review, most of the provisions are expected to stand.

Human rights groups want greater oversight by courts, arguing that the bill would grant excessive powers to security forces whose suspicions could stem from flawed or incomplete intelligence.