The pair, who police said were seized in the southern port city a few moments apart from each other, were radicalised French nationals aged 24 and 30, the Interior minister, Matthias Fekl, said.
Mr Fekl told a news conference: “These two radicalised men, born in 1987 and 1993, of French nationality, intended to commit in the very short-term – by that I mean in the coming days – an attack on French soil.”
He added that “a definite attack had been headed off.”
It’s thought that their target was scandal-hit presidential hopeful Francois Fillon, according to reports by AFP and Liberation newspaper.
His security officers were warned on Friday of “proven risks” on the right-wing candidate.
The Ministry of Interior “strengthened security in Montpellier”, where the candidate held a meeting on Friday, the source told AFP, referring to the presence of “snipers” at its public meetings.
There were also fears over Mr. Fillon’s meeting in Nice on Monday.
According to police, the two terror suspects were preparing an “imminent” attack.
They were arrested by the DGSI in the course of a flagrant investigation opened in Paris on 12 April for criminal criminal terrorist association and breach of arms legislation in connection with a terrorist enterprise.
A search of a rented apartment was also underway.
Guns and bomb materials were found in a raid, a source close to the inquiry told AFP.
The two suspects appeared to have turned to radical Islam during a term in prison.
Mr Fekl said security surrounding the elections and the candidates had been strengthened.
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, Mr 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 mobilised everywhere across France to ensure the security of French people and to ensure the presidential campaign goes smoothly,” he said.
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 programme.