Question: Is it permitted to visit the tombs of saintly persons (al-awliya) in a cetain period and connected with a journey (rihlah), although around these tombs many abominable things happen, such as the intermingling of women and men, the kindling of many lamps and whatever else there is ?
Response: The visit to tombs of saintly persons is a righteous deed (qurbah) that is desirable. The same holds true of the journey (to them), though the Sheikh Abu Muhammed (i.e. al-Juwayni, d 438H) said that the journey is only desirable if it leads you to the tomb of the Prophet (whereas visiting other tombs or traveling to them was prohibited). This opinion was rebutted by al-Ghazzali who argued that Abu Muhammed saw here an analogy with the prohibition of visiting mosques other than the three mosques (of Mecca, Medina and Jerusalem), yet the case is clearly different, because apart from these three all mosques are of equal standing and thus there is no benefit in visiting any of them especially. Saintly persons, on the contrary, differ in their closeness to God, and the visitors (to their tombs) will benefit according to the open and secret knowledge they possessed. Thus, travelling to them (individually) has its benefit. (…) As to the innovations (bida’) or forbidden acts (…), I say that righteous deeds (such as visiting tombs) should not be given up for that reason. It rather obliges everybody to perform (such deeds) and to combat the innovations, yea to abolish them if one is able to do so. (…) Therefore, the visit should be undertaken, but staying seperated from the women and condemning everything that seems forbidden, or even doing away with it if possible. (…) Of course, performing the visit during a time when there are no such abominable things happening is preferable”.
(al-Fatawa al-Fiqhiyya II p. 24)
(as translated in “The living and the dead in Islam”)