Visiting Madinah and praying in the Prophet's Mosque is highly recommended and is one of the most virtuous acts a Muslim can perform. However, it is essential to understand that visiting Madinah is not part of the Hajj rites — it is a separate, independent act of worship. A pilgrim may visit Madinah before Hajj, after Hajj, or even at a completely different time. Both timings are equally valid and there is no scholarly preference for one over the other.
Sheikh Ibn Baz stated that the purpose of visiting Madinah is to pray in the Prophet's Mosque, where one prayer equals one thousand prayers in other mosques (except Masjid al-Haram). The pilgrim should also send salam upon the Prophet and his two companions, pray in the Rawdah if possible, and visit Baqi cemetery and the graves of the Uhud martyrs. He emphasized that the trip to Madinah is for the sake of praying in the mosque, not 'visiting the grave' as a pilgrimage destination — this is an important theological distinction.
Sheikh Ibn Uthaymeen confirmed that there is no connection between Hajj and visiting Madinah in terms of Islamic law. Some pilgrims mistakenly believe that visiting Madinah is part of Hajj or that their Hajj is incomplete without it. This is incorrect. Hajj is complete with its own rites performed in Makkah, Arafat, Muzdalifah, and Mina. Visiting Madinah is a separate recommendation that can be done at any time. He advised pilgrims to plan their Madinah visit based on practical considerations — flight routes, hotel availability, and group schedule — rather than believing one timing is religiously superior.