Yes, women can visit graves according to the strongest opinion in the Hanafi Madhab. This ruling is based on multiple Hadith narrations permitting it.
قَالَ رَسُولُ اللهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ: نَهَيْتُكُمْ عَنْ زِيَارَةِ الْقُبُورِ فَزُورُوهَا
The Messenger of Allah (peace be upon him) said, ‘I forbade you from visiting graves, now visit them.’ (Sahih Muslim 977 – 106).
قُلْتُ: كَيْفَ أَقُولُ لَهُمْ يَا رَسُولَ اللهِ؟ قَالَ ” قُولِي: السَّلَامُ عَلَى أَهْلِ الدِّيَارِ مِنَ الْمُؤْمِنِينَ وَالْمُسْلِمِينَ، وَيَرْحَمُ اللهُ الْمُسْتَقْدِمِينَ مِنَّا وَالْمُسْتَأْخِرِينَ، وَإِنَّا إِنْ شَاءَ اللهُ بِكُمْ لَلَاحِقُونَ”
I (Sayidah Ayesha) said what should I say (when visiting graves) O Messenger of Allah (peace be upon him)? He (peace be upon him) said, ‘Say, peace be upon the inhabitants, the believers and the Muslims. May Allah (Most High) have mercy upon those of us who go before and those who pass away later. Indeed we will join you if Allah (Most High) wills.’ (Sahih Muslim 904 – 103).
There are many Hadith narrations that support the Hanafi position that women can visit graves, the ruling is the same as men. I have selected two narrations and mentioned them above, but there are many others besides these two.
In the first Hadith above we see the general encouragement to visit graves without women being excluded. Therefore, the ruling will apply to men and women equally, unless we find evidence to exclude women from the general ruling. The second Hadith is more specific, in it Sayidah Ayesha is being told what to say when visiting a grave. Had it been prohibited for women to visit graves then we would not find our beloved Prophet (peace be upon him) teaching a woman what to say when visiting.
وَفِيهِ دَلِيلٌ لِمَنْ جَوَّزَ لِلنِّسَاءِ زِيَارَةَ الْقُبُورِ وَفِيهَا خِلَافٌ لِلْعُلَمَاءِ. (شرح صحيح مسلم).
And in it is evidence for those who permit women to visit graves. And regarding it (the issue of women visiting graves) the scholars differ. (Imam al-Nawawi, Sharh Sahih Muslim).
Imam al-Nawawi acknowledged that the Hadith of Sayidah Ayesha (May Allah Most High be pleased with her) is evidence for scholars who permitted women to visit graves, whilst at the same time highlighting a difference of opinion on the issue.
ندب زيارتها” من غير أن يطأ القبور “للرجال والنساء” وقيل تحرم على النساء. (مراقي الفلاح).
It is recommended for men and women to visit graves, without stepping on them. It is said (in a weaker opinion) that it is Haram for women. (Imam al-Shurunbulali, Maraaqi al-Falah).
وَبِزِيَارَةِ الْقُبُورِ وَلَوْ لِلنِّسَاءِ لِحَدِيثِ «كُنْت نَهَيْتُكُمْ عَنْ زِيَارَةِ الْقُبُورِ أَلَا فَزُورُوهَا»
(قَوْلُهُ: وَلَوْ لِلنِّسَاءِ) وَقِيلَ: تَحْرُمُ عَلَيْهِنَّ. وَالْأَصَحُّ أَنَّ الرُّخْصَةَ ثَابِتَةٌ لَهُنَّ بَحْرٌ. (رد المحتار على الدر المختار).
Imam al-Haskafi: And (it is recommended) to visit graves, even for women. Due to the Hadith, ‘I forbade you from visiting graves, now visit them.’
Imam Ibn Abideen: His saying, even for women. It is said that it is prohibited for them (women). But the soundest opinion is that the dispensation is confirmed for them too, Bahr. (Radd al-Muhtaar).
As seen above, some Hanafi scholars did say women should not visit graves, but that is not the sound opinion of the Madhab.
Other scholars said they should not go, however that was in the broader context of women not leaving the house without necessity, it was not specific to graves. Based on this ruling, many Hanafi scholars said women are not allowed to go to the Masjid. That is a much broader discussion and requires a detailed analysis, it is incorrect to take that broader issue and specify it to visiting graves.
And Allah Most High Knows Best.
– Answered by Shaykh Noorud-deen Rashid (19.10.2021)
Is it permitted for women to enter a masjid?
How strong is the hadith about a menstruating woman not entering masjid?
Can women wear a nose ring in the Hanafi Madhab?
See also (video):