A man was shot and injured on Friday after attempting to ram his car into soldiers guarding a mosque in the southeastern French city of Valence, authorities said, adding that the driver's motives were unclear.

One soldier was slightly injured in the leg, and a passerby was hit in the leg by a stray bullet, the interior and defense ministers said in a joint statement.

The man, who was not immediately identified, was arrested and taken to hospital, according to the statement by Interior Minister Bernard Cazeneuve and Defence Minister Jean-Yves Le Drian.

Both ministers and French Prime Minister Manuel Valls were swift to send their backing to the soldiers.

"My support for the soldiers attacked in Valence. Fully appreciate our forces, mobilised for the security of France," Valls said in a tweet.

The soldiers in Valence are part of the reinforced security guarding places of worship and other sensitive sites.

Prudence over motive

The incident occurred in mid-afternoon, between two prayer sessions, when there was a large crowd outside, the rector of the mosque, Abadallah Dliouah, said.

The prefecture said the mosque was usually very calm, "and worship there takes place peacefully."

Nicolas Daragon, the mayor of Valence, said the driver twice rammed his vehicle at the soldiers, who were guarding the city’s main mosque.

The soldiers, some thrown to the ground, fired warning shots and one then fired to disable the driver, who was hit in the arm and leg, Daragon told iTele TV, praising the soldiers for their "remarkable" self-control.

The attacker's motives are being investigated, Daragon and the local prosecutor said.

The secretary-general of the prosecutor's office, Frederic Ouiseau, told the TV station that authorities must be "extremely prudent about the motive" of the attack.