PARIS (AP) An Islamic extremist with an arsenal of loaded guns was only prevented from opening fire on churchgoers because he accidentally shot himself in the leg, French officials said Wednesday.

The 24-year-old computer science student, who was also suspected in the death of a young woman whose body was found on Sunday just ahead of his arrest, had been flagged as a risk last year and earlier this year for intent to travel to Syria but there had been no specific reason to open a judicial investigation, Interior Minister Bernard Cazeneuve said Wednesday.

A French security official, who was not authorized to publicly release details, said the suspect â an Algerian who had lived in France for several years â was arrested in Paris Sunday after he apparently shot himself by accident and called for an ambulance. He was waiting outside for first aid when police arrived at the scene. They discovered a blood trail leading to his car, which contained loaded guns and notes about potential targets.

“Documents were also found and they prove, without any ambiguity, that the individual was preparing an imminent attack, in all probability, against one or two churches,” Cazeneuve said.

In the man’s apartment, in southeastern Paris, more weapons were found as well as Islamic extremist material, the official said. There was no immediate evidence that the suspect had direct ties to any organized groups, the official said.

Aurelie Chatelain, a 32-year-old Frenchwoman visiting Paris for a training session for her work, was found shot to death on Sunday morning in her car. The security official said Chatelain appeared to have been killed at random and ballistics evidence linked her death to the suspect.

The man was treated for a leg wound and remained hospitalized on Wednesday.

An attack on a church would mark a new type of target in France, where Jewish sites have been under increased protection since both the 2012 attack on a Jewish school and the killings at the kosher supermarket. But extremists have targeted Christians in the Middle East, most recently on Sunday when a video showed Islamic State militants in Libya killing groups of captive Ethiopian Christians and another released in February showing the deaths of captured Egyptian Christians.

“The terrorists target France to divide us,” Prime Minister Manuel Valls said Wednesday after leaving a top government meeting.

France has been on edge since the Jan. 7-9 attacks on the satirical newspaper Charlie Hebdo and a kosher supermarket left 20 people dead, including the three gunmen. In that case, at least two of the gunmen had been flagged to French intelligence â and the third had been recently released from prison after serving a sentence involving his ties to Islamic extremists â but surveillance was called off months before the attack.

The thwarted attack was announced hours before Cazeneuve met with executives from top Internet companies, including Google and Twitter, to talk about the government’s plan to increase online surveillance and block jihadi propaganda.

Copyright 2015 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.