Umayyad tradition of cursing Ali

Cursing Ali was a state policy pursued by the Umayyad Caliphate between 41 and 132 AH in order to discredit the partisans of Ali and enforce loyalty to the state. The caliphate of Umar II is said to have been an exception, but his reign was short and did not make serious dent in the Umayyad policies. The practice ended eventually only with the overthrow of the Ummayyads.
Background.
The third caliph Uthman belonged to the Umayyad clan of Mecca, during whose reign the Umayyad clan members took control of all the conquered territories in Syria, Egypt, Iraq and Persia. Scholar De Lacy O'Leary states that this led to a "complete secularising" of the Islamic state. After Uthman's assassination in 35 AH (656 CE), Ali became the caliph. Ali was one of the older Muslims, being prophet Muhammad's cousin and son-in-law. But the Umayyads led by Muawiya, then governor of Syria, refused to recognize him. A serious division of the Arab Muslim community into factions resulted with Ali's accession to power. A third sect of Kharijites, who were against both the Umayyads and the Alids, assassinated Ali in 41 AH (661 CE). Muawiya then became the caliph, founding the Umayyad dynasty that lasted till 132 AH (750 CE).
The practice.
Muawiya's rule lacked Islamic legitimacy, and used revenge for the wronged caliph (Uthman) as its permanent legitimation. Regular public cursing of Ali was thus enforced as a test of loyalty to the state.
On the order of Muawiyah I, Ali and his family were cursed as part of Friday congregational prayers from all the mosques of Umayyad caliphate.
Especially in Kufa, where the Alids were strong, cursing of Ali was intended to force the latent opposition into the open so that could be suppressed. After appointing Al-Mughira as the governor of Kufa, Muawiya instructed him:
However, Hujr bin Adi, acting as the spokesman for the partisans of Ali refused, giving 'witness' that "the one whom they censured and blamed was more worthy of excellence and the one whom they vindicated and extolled was more worthy of censure". Al-Mughira warned that he would invite the wrath of the caliph, but did not harm him.
The town of Sistan was an exception to the practice. The companion Sa'd ibn Abi Waqqas refused to comply with the order of cursing Ali, giving three reasons: 
Umar II (Umar Bin Abdul Aziz) replaced the cursing of Ali and his progeny, on the minbar during Friday prayers with verse 15 from Sura 59 (al-Hashr) and verse 90 of Sura 16 (al-Nahl) from the Qur'an. Al-Tabari mentions that the cursing of Ali definitely came to an end only with the fall of the Umayyad dynasty.
Al-Hajjaj and Cursing of Ali.
The revolt of Al-Ash'ath, which almost brought down the Umayyyad rule over Iraq, was crushed by Al-Hajjaj. Al-Tabari and Ibn Hajar mention a Shia notable Atiyah ibn Sa'd Awfi, who was captured by Muhammad bin Qasim and asked to curse Ali. Upon his refusal, he was punished with 400 lashes, as ordered by Al-Hajjaj. What happened to Attiya after this treatment is not clear. According to Al-Tabari and Ibn Hajar, he fled to Khurasan, but the Chach Nama states that he joined bin Qasim's invasion force as an officer. However, modern historians dispute the credibility of such reports in the Chach Nama.