Short answer
No. Visiting Madinah is not a rite of Hajj or umrah, and your Hajj is complete without it. But praying in the Prophet's Mosque and visiting his grave are among the most rewarding acts a pilgrim can do, and Hanafi scholars strongly recommend it.
Visiting the Prophet's Mosque and the grave of the Prophet ﷺ is highly recommended (some Hanafi jurists said close to wajib for someone able). It is not a rite of Hajj, and leaving it does not affect the Hajj. Hanafi jurists such as Ibn al-Humam encouraged intending the visit to the grave, which includes the mosque.
The four schools agree on this.
Explanation
Hajj and umrah are performed in and around Makkah only. Madinah has no rite of either, so a pilgrim who goes home from Makkah has a complete Hajj. Still, the Prophet ﷺ said a prayer in his mosque is better than a thousand prayers elsewhere except the Sacred Mosque, and travel for worship is made to his mosque, the Sacred Mosque and al-Aqsa.
Hanafi scholars treat visiting the Prophet's grave as one of the best acts of closeness to Allah. Some respected scholars hold that one should make the journey with the intention of the mosque, and that the visit to the grave then follows; this is a difference of wording more than of practice, since all agree the visitor goes to both and greets the Prophet with respect. Keep the tone of the visit calm, quiet and free of crowding and raised voices.
- Forty prayers (arba'in): many pilgrims try to pray forty prayers in the Prophet's Mosque. The hadith about this is weak according to many scholars. Praying there as much as you can is good, but forty is not a requirement.
- Riyad al-Jannah: the area between the pulpit and the Prophet's house, now entered by permit through the official app.
- Other visits: Quba Mosque, al-Baqi cemetery and Uhud are commonly visited.
If you go to Madinah before Makkah, you do not need ihram until you leave it; see ihram when going to Madinah first.
The evidence
Sahih al-Bukhari 1190
Sahih... صلاة في مسجدي هذا خير من ألف صلاة فيما سواه ...
"A prayer in this mosque of mine is better than a thousand prayers elsewhere, except the Sacred Mosque."
The great reward of praying in the Prophet's Mosque.
Sahih al-Bukhari 1189
Sahih... لا تشد الرحال إلا إلى ثلاثة مساجد ...
"Do not set out on a journey except to three mosques: the Sacred Mosque, the Mosque of the Messenger and al-Aqsa."
The Prophet's Mosque is one of three mosques people travel to for worship.
Where the ruling is recorded
- Fath al-Qadir, Kitab al-Hajj, closing section on visiting the Prophet's grave. Ibn al-Humam's discussion of the visit and its intention.
- Radd al-Muhtar (Ibn Abidin), Kitab al-Hajj, end of the chapter, on the visit. The visit is highly recommended and not part of the rites.
- al-Fatawa al-Hindiyya, Kitab al-Manasik, closing chapter on visiting the Prophet's grave. Manners of the visit.
This answer is pending review by the scholars on our team. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.