The mosque came to the grave, not the other way around. The Prophet Muhammad was buried in a room adjoining his mosque in Medina, and the burial place entered the building's perimeter only when a later expansion absorbed the surrounding residential quarters. The distinction matters. It separates the original burial from the architecture that later enclosed it.
The room was a home before it became an enclosure. Muhammad was buried where he died, in the apartment of his wife Aisha, beside the mosque he had established. Abu Bakr and Umar, the first two caliphs to succeed him, were subsequently buried there as well. The chamber remained distinct from the prayer space for years, even as the mosque itself grew. Its eventual incorporation was not a decision to move the graves. It was a change in the boundary around them.
Imperial building policy redrew that boundary. Under the Umayyad caliph Al Walid, the governor of Medina, Umar ibn Abd al Aziz, oversaw an enlargement that included the apartments adjoining the mosque, bringing the burial chamber within the expanded complex. The chamber remained enclosed, rather than becoming an open grave in the prayer hall; later construction added protective barriers around it. Today, the green dome above the area marks a site revered by Muslims, while the mosque's minarets and courtyard umbrellas testify to the scale of subsequent rebuilding. Beneath the dome lies a quieter architectural paradox: a room that stayed in place while the building around it changed.