An 84-year-old man who once stood as a far-right candidate in local elections has been arrested on suspicion of carrying out a shooting and arson attack that injured two people outside a mosque in south-west France. Two men aged 74 and 78 are in a serious but stable condition in hospital after the incident in Bayonne on Monday afternoon.

Police said a man tried to set fire to the door of the mosque and that when he was interrupted, he opened fire. The man then set fire to a car before fleeing, police said.

The suspect was arrested close to his home in the Landes, 10 miles away. The two injured men are believed to have been worshippers at the mosque.

A police source told Reuters that the suspect was a candidate in local elections in the Landes in 2015 for Marine Le Pen’s far-right party, Front National, which has since been renamed National Rally. He took 18% of the vote in the first round.

Nicolas Bay of the National Rally confirmed to Cnews TV channel that the suspect had been a candidate, but he had left the party saying its ideas didn’t suit him. Bay said: “He is an extremist who had no place in our ranks and who left.”

In a statement, the National Rally said the suspect had been removed from his local federation following the 2015 local elections after comments found to be “against the spirit and political line” of the party. He had left the party.

The French president Emmanuel Macron condemned the “hateful” attack, saying: “The republic will never tolerate hate”. He promised to “protect our Muslim fellow citizens”.

France’s interior minister, Christophe Castaner, offered his “solidarity and support to the Muslim community” over the attack and said he felt their “shock and fear”.

Le Pen condemned what she called an “unspeakable attack” and said it was “absolutely contrary to the values of our movement”. She said: “These crimes must be dealt with with the utmost severity.”

France has been grappling with a fresh political row over the Muslim headscarf and calls by some on the right to ban mothers in headscarves from volunteering on school trips.

This month 90 personalities, including actors and writers, signed an open letter in Le Monde calling on the president, Emmanuel Macron, “to say with force that Muslim women, whether they wear a headscarf or not, and Muslims in general have a place in our society – and to refuse our fellow Muslim citizens being monitored, stigmatised or denounced for the practice of their religion”.

Jean-Luc Mélenchon, leader of the leftwing France Unbowed party, tweeted on Monday: “In Bayonne the harassment of Muslims has produced its effect. Enough is enough now.” He called on all public figures to “stop encouraging hatred”.

Local residents, fire and police officers stand outside the Bayonne mosque after the incident. Photograph: STR/AP

Hours before the mosque attack in Bayonne, Macron had met Muslim leaders at the Élysée Palace and urged France’s Muslim community to step up the fight against “separatism”, in the wake of a recent attack by a radicalised police employee who stabbed four colleagues to death in Paris.

There have been intermittent attacks on mosques in France in recent years. In 2007, 148 Muslim headstones in a national military cemetery near Arras were smeared with anti-Islamic slurs and a pig’s head was placed among them. In March this year, workers building a mosque in the south-western town of Bergerac found a pig’s head and animal blood at the entrance to the site.

Mosques were also targeted after the killing of 12 people at the satirical magazine Charlie Hebdo in 2015. Dozens of mosques were attacked by arsonists, and others with firebombs, grenades or gunfire.