The Holy Prophet (Sallallahu alaihi wa sallam) was born in Makkah. On the orders of Allah, He (Sallallahu alaihi wa sallam) emigrated to Madina. The Ka’aba is in Makkah. All the articles of Haj are performed in Makkah, Muzdalifa and ‘Arafaat. If Allah wanted so, He could have made the blessed grave of the Holy Prophet (Sallallahu alaihi wa sallam) anywhere among these places, but it is not so. Allah has made the blessed grave of the Holy Prophet (Sallallahu alaihi wa sallam) in Madina, so that visiting the Holy Prophet (Sallallahu alaihi wa sallam) should not be for the sake of Haj, but that a separate journey should be made to visit the blessed grave of the Holy Prophet (Sallallahu alaihi wa sallam) as Hadhrat Khwaja Banda Nawaz (May Allah shower His mercy on him) says: It is the design of Allah that the blessed grave of the Holy Prophet (Sallallahu alaihi wa sallam) is not in Makkah so that visiting the Holy Prophet (Sallallahu alaihi wa sallam) is not for the sake of Haj. After Haj, a separate journey has to be made to Madina.
As per the opinion of Imam Shafa‘ee, like Makkah, Madina is also a divine sanctuary (Haram), but everyone agrees about respecting it.
(Jawame’ Ul Kalim, Pg. No. 361)