Shiraz is believed to have been founded around 694 (74 A.H.) by Mohammad ibn Yusuf Saqqafi, the Persian general in the service of the Umayyad caliph, and brother to Hajjaj ibn Yusuf, the viceroy of Baghdad. Local tradition has it that in a dream Mohammad saw a group of angels who descended to earth and prayed, kissing the land on which they stood. The angels addressed Mohammad and ordered him to build a town here. Astonished, he woke up and rushed for the place, which he found exactly as it had appeared in his dream. This was allegedly the site where now stands Shiraz, founded by Mohammad in obedience to the angels' command. The majority of early Islamic historians affirm this belief, stating that Shiraz is an Arab settlement, which at the time of the Muslim conquest in the days of Caliph Omar was the campground of the army sent to besiege Estakhr.
However, a much more ancient origin of the city has long been locally rumored. One legend attributes the city's founding to the half-mythological king Tahmuras the Demon-Binder, while another gives the credit to Fars, allegedly the great-grandson of Noah. Some medieval geographers report that by the time of the Muslim conquest of Fars, the site of Shiraz already held the remains of an ancient and very strong citadel called Fahndar (the remains of which can still be found on the Qal'e-ye Bandar Mountain rising above the Delgosha Garden, and several fire temples. Archeologists confirmed the pre-Islamic origin of Shiraz when they found in Persepolis clay tablets recording the wages of workmen who built Darius's palaces there in 518 B.C. Some of these laborers came from Shi-Razi-ish, "the Town of Secrets” (perhaps the place where the royal archive had been kept before Persepolis was founded). This suggests the name "Shiraz” an etymology more likely than any of the earlier guesses. Several Achaemenid stone wells in the environs of Shiraz also vouch for the existence of the city at least since the Achaemenid period. The ruins of Abu Nasr Palace and the stone bas-reliefs of Barm-e Delak testify to the importance of the area during the Parthian and Sasanid periods. The Sasanid kings, having divided the province of Fars into five khurreh (counties), chosen Shiraz to be the capital of one of them, Ardashir-khurreh. The other four counties were Shapur-khurreh (with the capital in Bishapur, Darabgerd, Estakhr, and Arjan.
The Shahnameh also mentions the name of Shiraz in its narration of the story of the Sasanid king Piruz, son of Yazdgerd II. During his war campaign against a Turk ruler, Piruz entrusted his domestic affairs to his renowned general Safrai, who was, according to Ferdowsi, a native of Shiraz. All things considered, it is perhaps best to say that although Shiraz has been in existence since the pre-Islamic period, its rise to prominence is owed to the Arabs, when they swept through the Fars territory in the early years of Islam. During Mohammad ibn Yusuf's governorship of the city, Shiraz became very prosperous. Yaqut, the 13th-century geographer, writing about this period, likened the city to the belly of a lion, in the sense that goods were carried into it from all quarters - a conceit introduced to support the fanciful etymology of Shiraz from Shir, the Persian word for "lion". It may be presumed, for lack of contrary evidence, that Shiraz shared a lot of all provincial cities until the decline of the Abbasid Caliphate in the 9th century. By this time, Shiraz had been turned into an important Shiite center and had even acquired a deeply venerated Shiite shrine when Ahmad ibn Musa was martyred and buried in the city in 835. In 840, Shiraz reached an even higher level of prosperity when it was designated the southern capital of the Saffarid state, founded by Yaqub Leis Saffarid. His bother Amru, the second ruler of this remarkable dynasty, built the Congregational Mosque, the oldest building in the modern city, During this period, the region of Fars was divided into four counties: Fars (with the capital in Shiraz), Shabankareh (with the capital in lj, Larestan, and Kohkiluyeh.