Ibn ul-Amir al-Haj said: “Near Zulkhulayfah there are wells, which called by people who lived near “Wells of Ali”. Narration that Ali fought against genies in those wells is a lie”.
Source: Mulla Ali al-Kari al-Hanafi “Masnua fi marifat ahadeth al mawdoa” p361, #477.
Fatwa from islamqa:
The claims that ‘Ali fought against the Jinn are baseless lies Is it true that Imaam ‘Ali (may Allaah be pleased with him) fought against the jinn? This is narrated in the book Ghazawaat al-Imaam ‘Ali, which says that he fought them until he sent them down to the seventh earth. What is your opinion of this book?
Praise be to Allaah.
All of this is baseless. He did not fight the jinn and no such thing happened at all. Rather this is false and is one of the lies and fabrications that people have invented. Abu’l-‘Abbaas Shaykh al-Islam Ibn Taymiyah (may Allaah have mercy on him) stated this clearly and said: “It is a lie which has no foundation. It is one of the false stories fabricated by the liars.”
Majmoo’ Fataawa wa Maqaalaat Mutanawwi’ah li Samaahat al-Shaykh al-‘Allaamah ‘Abd al-‘Azeez ibn ‘Abd-Allaah ibn Baaz (may Allaah have mercy on him), vol. 9, p. 277