All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Visiting the grave of the Prophet or Madeenah, is not one of the rituals of Hajj. However, if a pilgrim wants to visit the Prophet’s mosque in Madeenah and to travel there for the purpose of worship, acting according to the saying of the Prophet : “Do not travel for the purpose of worship except to three Mosques: Al-Haraam Mosque (in Makkah), the Mosque of the Prophet (in Madeenah) and Al-Aqsa Mosque (in Palestine).” [Al-Bukhari and Muslim from the Hadeeth of Abu Sa’eed Al-Khudri]; then this is permissible.
Therefore, if someone travels there for the purpose of worship, it is something good and desirable. In this case, it is permissible for him (the pilgrim) to visit the grave of the Prophet as part of visiting the Prophet’s mosque. However, whoever performs Hajj without visiting Madeenah, his Hajj is correct and complete.
For more benefit, please refer to Fataawa 86597 and 131677.
Allah knows best.