At the time Mohammad was born there, Mecca was a central place for polytheistic worship. We don’t have much to go on, for its history.
The Quran suggests a faith-based account of Mecca’s history. The story begins with Abraham’s having gone to Egypt, where his wife Sarah was taken into Pharaoh’s house. When Pharaoh realized that she was already married, he sent her away; the Muslim account adds that he was so impressed with her piety that he gave his daughter, Hagar (Hajar in Arabic), to be her servant. Hagar gives birth to Abraham’s first child, at Sarah’s request. Later, Sarah demands that Hagar and her son Ishmael be sent away, but Abraham sends them away with honor. He takes a retinue of servants and accompanies Hagar and Ishmael to a new place, then stays long enough to help build the nub of a new town. This town is Mecca, also called Becca (or Bakkah or Makkah).
Abraham comes back to visit Ishmael, who has married into the local tribe of Jurham, keepers of the Well of Zamzam, which an angel revealed to Hagar when they were thirsty. (see picture below, the well now preserved in a building)
On such a visit, Abraham helps his son build a temple for God: the Ka’aba (Surah 2:125, “And We made the House a focal point for the people, and a sanctuary. Use the shrine of Abraham as a place of prayer. And We commissioned Abraham and Ishmael, “Sanctify My House for those who circle around it, and those who seclude themselves in it, and those who kneel and prostrate.”). Muslims believe that for several generations, the descendants of Abraham periodically came to visit Ishmael’s family and worship at the Ka’aba.
Secular, non-Muslim accounts can’t confirm any of this; archeology and outside records have not been able to establish when Mecca was founded. All accounts agree that the Ka’aba was an important structure during Muhammad’s lifetime, and that it was part of the polytheistic system. In the Muslim understanding, idol-worship was a degradation of its original purpose, signifying loss of knowledge of the true God. All accounts also agree that the Ka’aba we have now can’t possibly be the original one, whenever it was built; in a story from Muhammad’s life, he witnesses a rebuilding of the Ka’aba. In the story, Muhammad finds a tactful way to keep the leading men of the city from quarreling over who is to lift the Black Stone into place in the new structure.
Later Muslim records tell of the structure’s being destroyed by fire or war. The part that remains the same is the black stone, though at one time, it was stolen and broken, and has now been encased in silver and restored.
Mecca was one of the pilgrimage sites that hosted a religious festival. It seems to have been linked into the South Arabian economic and social orbit, so the festival may have been similar to Marib’s annual pilgrimage to Almaqah. But Mecca was also on the edge of the great desert, and it operated as a caravan hub. People from many parts of Arabia came through Mecca, including nomads who were at war against each other before and after the festival’s truce.
Mecca was a point on the Incense Route, the road that led up the western coast of Arabia from Yemen to Jordan, but it was also near the seacoast. I believe gold had also been mined in that center-western part of Arabia, so in addition to incense and pearls, gold would have been traded through Mecca. Several caravan roads crossed near Mecca, so it was a major provisioning stop.
The city was basically in the coastal plain, but also at the foothills of the mountains that lead into Arabia’s inner plateau. There were rocky hills all through the city and small mountains just outside it. The city has now grown to include some of those mountains.
Mecca was ruled by the tribe of the Quraysh, of whom Mohammad was a minor member. The Quraysh ran the city as a business, including the pilgrimage festival. Their chief god was Hubal, along with a trio of goddesses—sisters—Manat, Al-Lat and Al-Uzzah.
The goddesses had their own shrines near Mecca, where Manat was the goddess of fate, and one of the others (Al-Lat?) may have represented the moon. Hubal was a god of divination; arrows were cast in front of his idol, and the way they fell determined the omen and its message. But the Ka’aba included other gods, so that most options were available to pilgrims: Almaqah and other gods of South Arabia, gods of Canaan and Greece, and by Muhammad’s time, even an icon of Mary. For the Quraysh, the point of the pilgrimage festival was that it brought a lot of business into the town. Doctrine was very low on the priority chain.
When pilgrims came to Mecca, they worshipped at the Ka’aba by walking around it. They also touched or kissed the sacred stone, and sometimes they used it to make binding oaths, pouring water across it and using the water as sacred. If there was a belief that the stone stood for something, we don’t know of it. Periodically, the Ka’aba had to be rebuilt, as it was in Muhammad’s time. When the city was under attack, the Ka’aba was a major target, since it functioned as the city’s spiritual center.