Police arrested two men in a raid on a flat in the southern city of Marseille and found explosives, guns and an Islamic State flag, anti-terrorism prosecutor Francois Molins said.
Security forces had been on the trail of the two men since December, Molins said.
The search became more urgent earlier this month when they discovered that one of them had tried to send a video to members of the Islamic State extremist group either declaring allegiance or claiming an attack.
The video, intercepted on April 12, showed weapons similar to those found in the raid, an Islamic State flag, and a newspaper front page showing one of the candidates in the presidential election, Molins said.
France has been on high alert since deadly attacks in Paris, Nice and elsewhere over the last two years – mostly claimed by the Islamic State extremist group – left at least 238 people dead.
Authorities say they have made hundreds of arrests since the beginning of last year, but Tuesday’s incident was the first with a possible link to the hotly contested election campaign.
The newspapers Le Monde and Le Figaro, quoting unnamed sources close to the investigation, said that the front page in the video showed a photograph of conservative candidate Francois Fillon, arousing fears that he might be the target of a planned attack.
Molins said evidence to date indicated that the two suspects were preparing “an imminent violent act on French territory, but it is not yet possible to say precisely when, or what their target or targets were.”
Security forces located their flat on Tuesday morning and moved in, Molins said. The older man, who had tried to send the video, was arrested as he left the building. The other suspect was nabbed 35 minutes later in the stairwell.
Some of the 3 kilograms of TATP explosive found was ready for use. An automatic rifle, handguns and an Islamic State flag as well as jihadist images and pictures of children killed in airstrikes were also found.
Le Monde reported that security forces had strengthened security measures for the rallies of several candidates, including Fillon, far-right leader Marine Le Pen and centrist Emmanuel Macron, in recent days.
Interior Minister Fekl stressed that 50,000 police and troops would be securing the two stages of the presidential vote on Sunday and on May 7.
“A few days ahead of a major election for our country, I wish to recall that everything has been put in place to ensure the security of this important date for our democracy and our republic,” he said.
Fillon meanwhile downplayed the development as a “crime incident,” and said it should not lead to the campaign being sidetracked.
He vowed to focus on “the priorities of the French people: the struggle against unemployment and the struggle against insecurity in general.”
Macron said it underlined the importance of his call to take “strong action” against the terrorist threat.
“It is a challenge that calls on us all to unite, because the terrorists want nothing more than to divide us,” he argued.
But Le Pen, who is vying with Macron for first place in the polls ahead of Sunday’s first round of voting, was less conciliatory.
She claimed that “violence reigns in France to a point where extreme left militias and Islamo-leftists can carry out daily attacks unpunished.”
That appeared to be a reference to occasionally violent protests by leftists against her public meetings.
On Monday night, police used tear gas to disperse protesters outside a Le Pen rally in Paris, while two topless female protesters interrupted the candidate’s speech.
The top two candidates in Sunday’s poll will go through to a run-off scheduled for May 7.