"A prayer in my mosque is better than one thousand prayers in other mosques except Al-Masjid Al-Haraam (in Makkah).” Visiting the mosque of the Prophet is an act of Sunnah (tradition) and it can be done before or after performing Hajj. It was narrated on the authority of Abu Hurayrah that the Messenger of Allah said: “A prayer in my mosque is better than one thousand prayers in other mosques except Al-Masjid Al-Haraam (in Makkah).” [Al-Bukhari and Muslim] Ibn ‘Umar narrated that the Prophet said:
‘Abdullah ibn Az-Zubayr narrated that the Messenger of Allah said: “A prayer in my mosque is better than one thousand prayers in other mosques except Al-Masjid Al-Haraam (in Makkah) and a prayer in Al-Masjid Al-Haraam is better than one hundred prayers in this Masjid of mine.” [Ahmad, Ibn Khuzaymah and Ibn Hibbaan]
It was narrated on the authority of Jaabir that the Prophet said: “A prayer in my mosque is better than one thousand prayers in other mosques except Al-Masjid Al-Haraam (in Makkah) and a prayer in Al-Masjid Al-Haraam is better than one hundred thousand prayers in any other mosque.” [Ahmad and Ibn Maajah] There are many Ahadeeth (narrations) that indicate this meaning.
When one reaches the mosque, it is recommended to enter with the right foot and say: "Bismillaah wa as-salaatu wa-assalaamu ‘ala rasoolillaah. A‘oothu billaahi Al-‘Atheem wa biwajhihi al-kareem wa sultaanihi al-qadeem min ash-shaytaan ar-rajeem; al-hamdulillaah; Allahumma iftah li abwaaba rahmatik (In the name of Allah, and may His peace and blessings be upon the Messenger of Allah. I seek refuge with Allah, the Great and with His honorable Face, and with His eternal Sovereignty from the accursed devil. O Allah, open the gates of Your Mercy for me).” This supplication should be said when entering any mosque as the mosque of the Prophet does not have a special supplication that is peculiar to it.
After this, one should pray two Rak‘ahs and supplicate Allah The Almighty with what he likes pertaining to this life and the Hereafter. If one manages to pray these two Rak‘ahs in the Rawdhah, this would be better as the Prophet said: “Between my house and my pulpit is one of the gardens from the gardens of Paradise.” After praying, one should visit the grave of the Prophet and stand before the grave respectfully and say in a low voice, “Assalaamu ‘alayka yaa rasoolallaah wa-Rahmatullaahi wa-Barakaatuh (May the peace, blessings and mercy of Allah be upon you, O Messenger of Allah).”
It was narrated on the authority of Abu Hurayrah that the Messenger of Allah said: “No one greets me with salaam but Allah returns my soul to me to return the greeting.” [Abu Daawood: Hasan] It is alright to say, "Peace be upon you, O Prophet of Allah! Peace be upon you, O best of mankind. Peace be upon you, O master of the messengers and exemplar of the righteous. I bear witness that you have delivered the message, fulfilled the trust, and given sincere advice and striven for Allah with the striving due to Him," as these are all attributes of the Prophet . Allah The Almighty Says (what means): {…O you who have believed, ask [ Allah to confer] blessing upon him and ask [Allah to grant him] peace.} [Quran 33:56]
After this, one should greet Abu Bakr and ‘Umar . When greeting the Messenger of Allah and his two Companions, Abu Bakr and ‘Umar Ibn ‘Umar used to say, “Peace be upon you, O Messenger of Allah; peace be upon you, O Abu Bakr; peace be upon you, O my father," and he would leave. Visiting the graves is lawful for men. Women should not visit the graves as the Prophet cursed women who visit graves frequently and those who build mosques over graves.
As for visiting Madeenah in order to visit the mosque of the Messenger of Allah supplicate Allah The Almighty in it and do similar acts that are lawful in all other mosques, it is permissible for both men and women, as there are many Ahadeeth that prove this. It is permissible for the visitor to pray the five obligatory prayers in the mosque of the Messenger of Allah to supplicate Allah The Almighty and remember Him a lot, and to pray supererogatory prayers in order to attain the great reward given for these deeds when performed in the mosque of the Prophet . It is also recommended to pray in Ar-Rawdhah Ash-Shareefah as the Prophet said: “Between my house and pulpit is one of the gardens of Paradise.” As for the obligatory prayers, one should hasten to perform them and be keen on joining the first row as much as possible even if he prays in the eastern extension. It was narrated that the Prophet used to encourage people to pray in the first row as he said: “Were people to know the blessing of pronouncing Athaan and standing in the first row, they would even draw lots to secure these privileges." [Al-Bukhari and Muslim]