The attack set off panic and a scramble for shelter, and officers began searching for possible accomplices after the attack.

Near midnight, President François Hollande said in an address to the nation that the attack appeared to be an act of terrorism. The Islamic State claimed responsibility in a message posted on a jihadi channel, and the Paris prosecutor said he had opened a terrorism investigation.

The attack came only days before the start of a presidential vote that could reverberate across Europe, and as the 11 candidates were having their final quasi-debate on the France 2 television network.

Analysts have been saying for weeks that an attack just before the first vote, or between the first vote and the runoff on May 7, could tip the election toward a candidate perceived as tougher on crime and terrorism. The far-right leader, Marine Le Pen, has hardened her stand against Muslim immigration in the campaign’s final days, linking it to security fears, while François Fillon has pledged to eradicate Islamic terrorism.