A man wielding a knife has attacked three soldiers patrolling outside a Jewish community centre in Nice, in the south of France.
The soldiers were wounded and police said the assailant was captured.
Nice Mayor Christian Estrosi told French TV that a second man had been arrested in connection with the stabbing.
The attacker was expelled from Turkey last week and questioned upon his return, French media reported.
France has been on high alert since last month's terror attacks in Paris by three Islamist gunmen, in which 17 people were killed.
After the attacks, 10,500 soldiers were deployed outside sensitive sites including Jewish and Muslim centres as well as media buildings.
The soldiers attacked in Nice were guarding a building in the city's Massena square which houses the Jewish community centre and a Jewish radio station.
The attacker had been travelling on the tram without a ticket, but left the tram when ticket collectors approached him and he then targeted the soldiers.
He slashed one soldier in the cheek, injured another in the leg and a third on the chin, reports said.
He tried to escape but was caught by a shop owner, tram workers and police patrolling nearby.
He has been named by the mayor as Moussa Coulibaly, aged 30 and of Malian origin, but there appears to be no link with the Paris gunman Amedy Coulibaly, who killed four people in a Jewish supermarket in January.
The suspect had been expelled from Turkey last week, having flown there from the Corsican city of Ajaccio on 28 January, a security source told AFP news agency.
He had raised suspicions among border officials when he bought a single fare to Turkey, and French intelligence asked the Turkish authorities to send him back, the source said.
Although he had been questioned, no judicial action had yet been taken.