PARIS — France has foiled a terrorist plot and detained three men who are accused of plotting to enter a military base, stage an attack there and film it, according to the Interior Ministry.

It was unclear how far the alleged plot had advanced or which base was the intended target. The eldest suspect, 23, had served in the French military, Interior Minister Bernard Cazeneuve said Wednesday. The other two are under 20.

A fourth person, a 16-year-old, was also detained but later released for lack of evidence, according to judicial sources. The four were picked up in different parts of France on Monday at dawn, Mr. Cazeneuve said.