Clément Baur and Mahiedine Merabet had pledged allegiance to Isis in a video intercepted by French and British intelligence services on 12 April.
It included footage of children killed in alleged coalition air strikes in Syria and Iraq and showed an Uzi submachine gun on a table, next to the front page of France’s Le Monde newspaper from March.
It was dedicated to Francois Fillon’s election campaign and is believed to be one of the factors leading investigators to believe the plot was timed for voting starting on Sunday.
Francois Molins, the Paris public prosecutor, would not confirm which candidate was targeted but confirmed the three frontrunners – Mr Fillon, Emmanuel Macron Marine Le Pen – had been alerted to the risk.
“Investigators managed to locate the apartment,” Mr Molins told a news conference.
He said a tip-off from another country indicated Merabet was likely to carry out an attack and was seeking to contact Isis militants, either to pledge allegiance or ask the group to claim responsibility for the planned attack.
“These two radicalised men intended to commit in the very short-term – by that I mean in the coming days – an attack on French soil,” said the interior minister, Matthias Fekl.
They were arrested on Tuesday morning at a flat they had been renting for less than three weeks in Marseille, where the Uzi, two handguns, ammunition, a hunting knife, a map of the city, a balaclava and a GoPro camera were found.
An Isis flag and Quran was discovered, as well as a mask associated with the Anonymous hacking collective and a chestnut wig, suggesting plans for a disguise.
Mr Molins said jihadi propaganda was also found, alongside 3kg of homemade triacetone triperoxide (TATP) explosive drying in three packages – only one of which was ready for use.
The volatile explosive, known as the “mother of Satan”, is cheap to make using commercially available chemicals but difficult to detect, and has become a trademark of Isis’ plots and attacks including in Brussels and Paris.
Isis has shared bomb-making manuals on how to manufacture the substance, while calling on supporters to wage terror attacks against countries in the US-led coalition bombing its ever-shrinking territory in Syria and Iraq.
Baur, 23, is suspected of attempting to join the so-called Islamic State in Syria after being freed from prison, where he had been jailed for petty crime under the name Ismail Djabrailov.
He was put in a cell in Sequedin prison with Merabet, 29, who was serving a jail sentence for drug dealing, and the pair became inseparable.
Baur had converted to Islam at the age of 14 and was in contact with the Chechen community of Nice, while Merabet was suspected of attempting to obtain weapons after being released in 2016.
His former home in Roubaix, near Lille, was searched by counter-terror police who uncovered an Isis flag and jihadi propaganda in December, but Merabet was not there and a “roommate” – later revealed to be Baur – gave police a false name.
Merabet, who had 12 convictions, taunted police in the town by sending them his ID and debit card on 4 April, with the message: “I’m giving you my ID and my card as because of you, I have more use for them.
“I will soon surrender, we will talk. To you the security forces, what do you want from me?
“Let me breathe, I have nothing to say to you. I live on love alone, I meditate. Leave me alone. Bye!”
The French pair’s criminal history fits with a long line of Isis militants, including most of the Paris and Brussels attackers, some of whom also spent time together in prison.
The group is known to directly target former gang members and convicts looking for redemption in online recruitment, with more than half of known European jihadis having a criminal past.
Baur’s family had alerted authorities to his radicalisation and French officials said he had links to jihadi networks in Belgium, which had started a separate investigation.
The Brussels prosecutor said an alert had been issued over Baur, who was wanted for questioning, but he had not been traced in Belgium since the end of 2015.
The plot was foiled just days before the first round of voting in the French presidential election, where security has taken centre stage following the murder of almost 240 people in two years of terror attacks.
With the country still under a repeatedly extended state of emergency, Mr Fekl said 50,000 police, gendarmes and soldiers would be deployed for each leg of the election, and security reinforced for the candidates.
Join our commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies