What is the Sharee‘ah ruling on a person who goes to Al-Madeenah under the pretext of performing prayer in the Masjid of the Prophet, sallallaahu ‘alayhi wa sallam, while he actually intends to visit his grave?
All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
It is permissible for a person who is near to Al-Madeenah and can reach it without travel to have the intention of visiting the grave of the Prophet, sallallaahu ‘alayhi wa sallam, even if he solely went for that purpose. As for those who travel to Al-Madeenah, it is permissible for one to visit the grave of the Prophet, sallallaahu ‘alayhi wa sallam, if he went with the intention of performing prayer in the Masjid. But if he traveled with the sole intention of visiting the grave, this is not approved under Sharee‘ah according to most scholars. Nevertheless, this is not expected to happen by those who know the virtue of performing prayer in the Masjid of the Prophet, sallallaahu ‘alayhi wa sallam.
Shaykh-ul-Islam, Ibn Taymiyyah said:
A person who is knowledgeable about Sharee‘ah does not do that. He is fully aware that the Messenger of Allaah, sallallaahu ‘alayhi wa sallam, made it desirable for Muslims to travel to his Masjid and perform the prayer there. So, how is it that such person does not make praying in the Masjid his basic objective while he is going there in all cases.. Intention is absent only in case of ignorance. A person may be ignorant that traveling to the Masjid of the Prophet, sallallaahu ‘alayhi wa sallam, is desirable because of the Masjid itself, not the grave; or the traveler may be unaware that he will reach the Masjid. When a person is knowledgeable about the two matters, it is necessary that he intends traveling to the Masjid to pray there in the first place.Allaah Knows best.
You can search for fatwa through many choices