The Kaaba was rebuilt and restored in the year 605. During this construction, it is known that the Prophet Muhammad carried stones along with his uncle Abbas, and this act prevented a potential conflict among the Quraysh tribes who could not agree on sharing the honor of replacing the Black Stone (Hajar al-Aswad).
The Prophet Muhammad conquered Mecca due to the violation of the Treaty of Hudaybiyyah by the polytheists. Thus, the service of the Kaaba and the control of the Masjid al-Haram came into the hands of the Muslims.
After the Kaaba and its surroundings were cleansed of polytheistic symbols, the Prophet Muhammad performed two rakats of prayer inside the Kaaba. He then ordered Bilal al-Habashi to climb onto the roof of the Kaaba and call the adhan.