French police have thwarted an imminent "terror attack" and arrested two suspected radicals in the southern port city of Marseille, authorities said.
Paris prosecutor Francois Molins said at a news conference that the two suspects "were getting ready to carry out an imminent, violent action on national territory".
He said at this stage investigators have not determined "the day, the targets and the exact circumstances" of a potential attack.
France votes on Sunday in the first round of its two-stage election.
Extra safety measures are being put in place for the balloting after extremist attacks in the country that have made security one of the major issues of the presidential campaign.
Mahiedine Merabet, 29, and Clement Baur, 23, both French, were detained under arrest warrants for terrorist criminal association, according to a police document obtained by the Associated Press.
Mr Molins said Merabet had in recent days tried to send a video to Islamic State to claim "allegiance or responsibility" for a potential attack.
Baur was signalled to authorities by his family in 2015 as radicalised, with the possible intention of going to Syria.
He had links with Belgian jihadi networks, Mr Molins said.
In their Marseille apartment police found one automatic rifle, two handguns, quantities of ammunitions and 3kg of explosives as well as products and equipment to make explosives, Mr Molins said.
He said a flag of IS, a video camera, six mobile phones, one laptop, a black hood, a mask and a wig were also discovered.
The two men were both known to police and intelligence services for their religious radicalism.
They met in prison in 2015, Mr Molins said.
President Francois Hollande hailed the "remarkable" arrests and the work of police.
Agents from the French domestic security agency, backed by elite police units, conducted the arrests.
France's fight against homegrown and overseas Islamic extremism has been one of the main campaign topics for presidential candidates.
Candidates on the right have been especially vocal, seeking to appeal to voters traumatised by IS-inspired attacks that have killed at least 235 people in France since January 2015, by far the largest casualty figure of any Western country.
With the terror threat "higher than ever", interior minister Matthias Fekl said "everything is being done" to secure the election, the candidates, their election headquarters and rallies.
He said more than 50,000 police, gendarmes and soldiers will be deployed in France and its overseas territories on Sunday and for the decisive second-round vote on May 7.