The very first construction of the Kaaba was done by Prophet Ibrahim (peace be upon him) and his son Ishmeel as a house of worhip to one God. Allah (the Glorified and Exalted) says in the Quran that this was the first house that was built for humanity to worship Allah (the Glorified and Exalted). Soon after Prophet Ibrahim (peace be upon him) died, people started filling the Kaaba with idols. It was not until Prophet Muhammad (peace and blessings be upon him) defeated the idol-worshippers that the idols inside the Kaaba were destroyed.
One of the Five Pillars of Islam requires every Muslim to perform the Hajj pilgrimage at least once in his or her lifetime if able to do so. Multiple parts of the Hajj require pilgrims to walk seven times around the Kaaba in a counter-clockwise direction. This circumambulation (Tawaf), is also performed by pilgrims during Umrah.
Muslims around the world face the Kaaba during prayers, no matter where they are. This is called facing the Qiblah.
As mentioned in this verse in the Quran, "Verily, We have seen the turning of your (Muhammad's) face towards the heaven. Surely, We shall turn you to a Qiblah (prayer direction) that shall please you, so turn your face in the direction of Masjid al-Haram. And wheresoever you people are, turn your faces (in prayer) in that direction." [2:144 ]
The Masjid al-Haram was built around the Kaaba. It is also the largest mosque in the world. It was first built under the leadership of the Caliph Omar Ibn al-Khattab (634-644) and has been modified continuously under several Muslim rulers. Omar, the first Caliph, ordered the demolition of some houses surrounding the Kaaba in order to accommodate the growing number of pilgrims and built a 1.5 meter high wall to delineate a large prayer area. During the reign of his successor Caliph Uthman Ibn Affan (644-656), the prayer space was enlarged and was covered with a roof carried on wooden columns and arches. In 692, after Caliph Abdul Malik bin Marwan conquered Mecca from Ibn Zubayr, the guardian of the holy site, the outer walls of the mosque were raised, the ceiling was covered with teak and the column capitals were painted in gold. His son, al-Walid (705-715), contributed to the Mosque of al-Haram by replacing the wooden columns with marble ones and by decorating its arches with mosaics. Later, Abbasid Caliph Abu Ja'far al-Mansur (754-775) added mosaics to the columns. He also doubled the size of the northern and western wings of the prayer hall and erected the minaret of Bab al-Umra on the northwest corner. In 777, due to the growing number of pilgrims, Abbasid Caliph al-Mahdi (775-785) ordered the rebuilding of the mosque, demolishing more houses around the Ka'ba. The new mosque enclosure centered on the Kaaba, measured 196 meters by 142 meters. It was built on a grid plan, with marble columns from Egypt and Syria, decorated with gilt teak wooden inlay. Al-Mahdi also built three minarets crowned with crenellations and placed above Bab al-Salam, Bab Ali and Bab al-Wadi of the mosque.