Even though the Safavids were not the first Shi’a rulers in Iran...
Even though the Safavids were not the first Shi’a rulers in Iran, they played a crucial role in making Shi’a Islam the official religion in all of Iran. There were large Shi’a communities in some cities like Qum and Sabzevar as early as the 8th century. In the 10th and 11th centuries, the Buwayhids, who were of the Zaidiyya branch of Shi’a Islam, ruled in Fars, Isfahan and Baghdad.
As a result of the Mongol conquest and the relative religious tolerance of the Ilkhanids, Shi’a dynasties were re-established in Iran, Sarbedaran in Khorasan being the most important. The Ilkhanid ruler Öljaitü and converted to Twelver Shi’ism in the 13th century. Following his conquest of Iran, Isma’il I made conversion mandatory for the largely Sunni population. The Sunni ulema, clergy, were reportedly either killed or exiled.
Isma’il I, despite his heterodox Shi’a beliefs, brought in Shi'a religious leaders and granted them land and money in return for loyalty. Later, during the Safavid, especially the Qajar period, the Shi’a ulema's power increased, and they were able to exercise a role, independent of or compatible with the government. Despite the Safavid's Sufi origins, most Sufi groups were prohibited, except the Ni’matullahi order.
Iran became a feudal theocracy: The Shah was held to be the divinely ordained head of state and religion. In the following centuries, this religious stance cemented both Iran's internal cohesion and national feelings, provoking attacks by its Sunni neighbors. After the disastrous invasion of the Mongols, in the 1200s, migrated Turks and Mongolian tribes adopted the Persian customs and even language.
In the 1300s, the Ilkhanids, a dynasty founded by "Genghis Khan's" grandson, Holagu Khan, had been an influential factor in Persia. During these turbulent years of 13th century, the Persians had submerged themselves deeper in Islamic devotion and Sufism. Towards the end of the 14th century, Timur (Tamberlane) claimed to be a descent from Genghis Khan's family. The disturbed conditions in Mongol Transoxania gave him in the town of Kish the chance to build up a kingdom in Central Asia.
He entered Iran in 1380, and in 1393 he reduced the Jalayirids’ power and domination after taking their capital, Baghdad. In 1402 A.D., he captured the Ottoman Sultan Bayezid at Ankara and conquered Syria then turned his attention to campaigns to the east of his quickly acquired and ill-cemented empire. He died in 1405 on an expedition to China.