The annual hajj pilgrimage, one of the five pillars of Islam, predates the faith by centuries, tracing its roots to the biblical patriarch Abraham - revered by Muslims as a prophet and the first preacher of their religion.
And as some 2.5 million people gather in this western Saudi city for the hajj, a must for every capable Muslim at least once in a lifetime, they begin rituals said to follow millennium-old instructions by Abraham, or Ibrahim, as he is known in the Muslim holy book, the Koran.
Muslims believe that a "sacred house" was built in Mecca by Adam, the father of the human race, in the same spot where Ibrahim and his son Ishmael are said to have rebuilt it and where the Kaaba, a massive cubic structure, lies.
The Koranic version of the story is that Ibrahim travelled with Hagar, the mother of their infant son Ishmael, to a barren valley and left both of them near the sacred house with some food and water that soon ran out.
Hagar's desperate runs between the two hills of Safa and Marwa in search of sustenance have been imitated by pilgrims ever since the prophet of Islam, Mohammed, ordered his followers to perform the hajj to Mecca.
Islamic tradition says Allah answered Ibrahim's prayer to look after his family by sending the angel Gabriel, who scratched the dry soil under the infant, triggering a sudden and continuous gush of water.
The resulting Zamzam Well is believed to have brought life into the area, bringing nomad Arabs to settle around it. Ishmael learned Arabic and married into Arab tribes. For Muslims, Mohammed is an offspring of Ishmael.
Ibrahim is said to have reconstructed the house of worship with Ishmael on returning to the area years later. The Koran speaks of Ibrahim as building the structure as the first house for worship on earth.
But the Kaaba was demolished and rebuilt several times, the last believed to be after floods in 1630.
As an indication of worshipping activities at the "sacred house," the Koran cites Allah's order to Ibrahim to rid the house of idols and purify it for pilgrims. He was also ordered to call people to hajj.
Mohammed did the same in 630 AD when he conquered Mecca with his followers as he entered the Kaaba and destroyed all idols placed there by Arabs to represent their pagan gods.
Islamic tradition says the meaning of Ibrahim's hajj was distorted over time, with the belief in one God that he preached losing ground to polytheism, and Arabs worshipping idols as proxies to God and filling the Kaaba with them.
It also says that, over the centuries before Islam, it turned into something resembling a fun-fair and lost its spirituality, with some pilgrims replacing prayers with clapping and whistling, and others even circling the Kaaba naked.
And just as Muslim pilgrims stand on Mount Arafat at the peak of every hajj, pre-Islamic pilgrims used to spend a day in the barren plain outside Mecca and return to the city circumambulating the Kaaba.
Arab tribes of Mecca, notably Mohammed's Quraysh, used the hajj to bring prosperity to their town, and the hajj became an occasion for several festivities, including poetry competitions. The Kaaba walls for a long time were used as notice boards for the most famous pre-Islamic Arab poems.
Pre-Islamic Arabs also used to perform the ritual of slaughtering animals as a sacrifice to God. That tradition is carried on by Muslims on their most important feast, the Eid al-Adha or feast of sacrifice, the day after pilgrims descend from Mount Arafat.
It is in honour of Ibrahim's obedience to God in preparing to sacrifice Ishmael, which God forestalled by providing the patriarch at the last minute with a lamb to kill instead. That contradicts the Old Testament's story of Abraham, which says he was about to slay his other son, Isaac.
But Islam stopped the Arab practice of splattering the blood of the sacrificed animals on the walls of the Kaaba.
Mohammed ordered his followers to perform the hajj on the ninth year of the Islamic calendar, the first year after he conquered Mecca.Reuse content