In the early hours of Saturday, the vandals painted a swastika on the floor outside the mosque in Sartene in the south of the island, as well as the slogan: "Arabi Fora" ("Arabs Out" in Corsican), police said.
The Moroccan imam, alerted by the noise, had gone to investigate when they shot at the door.
He escaped injury by taking cover.
State prosecutor Jose Thorel has launched an inquiry.
Violence against foreigners, especially North Africans, has risen in recent months in Corsica, where separatists have carried out low-key attacks since the 1970s.
About 50 attacks of a xenophobic nature have been registered this year.
Corsicans rejected an offer by Paris of limited autonomy in a referendum in July 2003.