Two Frenchmen arrested in Marseille on Tuesday planned to carry out an "imminent and violent attack" ahead of the first round of the presidential election on Sunday, France's interior minister said.
A machine gun, two hand guns and three kilos of TATP explosive were among the weapons found at a flat in Marseille raided by police.
The pair, who police said were seized in the southern port city a few moments apart from each other, were radicalized French nationals aged 24 and 30, the minister, Matthias Fekl, said.
"These two radicalized men ... intended to commit in the very short-term - by that I mean in the coming days - an attack on French soil," Fekl told a news conference.
A definite attack had been headed off, he said.
According to prosecutor Francois Molins, the two Frenchmen had met while sharing a cell in prison and were known to police as having turned to radical Islam.
France goes to the polls to choose a new president on April 23 and on May 7 in a two-stage election.
National security figures high on the agenda in the ballot after attacks by militant Islamists across France which have killed more than 230 people in the past two years.
With the country still under a state of emergency, Fekl said more than 50,000 police, gendarmes and soldiers would be deployed for each leg of the election.
"Everything has been put in place to ensure the security of this big event for our democracy and our republic. The security forces are mobilized everywhere across France to ensure the security of French people and to ensure the presidential campaign goes smoothly," he said.
Neither Fekl nor police gave any precise details of what attacks the pair had been planning and whether they were intending to target one or more of the election candidates.
Far-right leader Marine Le Pen, one of the foremost candidates, is scheduled to hold the last big rally of her campaign in Marseille this week, according to her program.
Separately, sources in the camp of conservative Francois Fillon said they had been warned there was a security risk for the right-wing candidate.
Want to enjoy 'Zen' reading - with no ads and just the article? Subscribe todaySubscribe now