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.