As in the case of the early caliphate, Safavid rule had been based originally on both political and religious legitimacy, with the shah being both king and divine representative. With the later erosion of Safavid central political authority in the mid-17th century, the power of the Shia scholars in civil affairs such as judges, administrators, and court functionaries, began to grow, in a way unprecedented in Shi'ite history. Likewise, the ulama began to take a more active role in agitating against Sufism and other forms of popular religion, which remained strong in Iran, and in enforcing a more scholarly type of Shi'a Islam among the masses.