At 15:20 local time (1420 GMT), the suspect was trying to set fire to the door of the mosque, then he shot two men who surprised him and tried to stop his attempt, the Pyrenees-Atlantiques prefecture said in a statement.
The armed man, who torched a vehicle before he ran away, was arrested shortly after near his home in Les Landes, it said.
Aged 78 and 74, the two victims were transferred to hospital, according to the statement.
Local media reports say the suspect was an elderly man in his 80s and had reportedly been a political candidate for Marine Le Pen's far-right National Rally party in provincial elections in 2015.
A firearm and a gas canister were reportedly found in his car.