To be a son of Quraish
All Muslim sects and factions deemed the Caliph a particularly prestigious position that had complex doctrinal requirements, with origins regarded as one of the most important eligibility rules. Over the course of the Caliphate's history, however, principles and practice often diverged. According to Ali ibn Muhammad Al-Mawardi's book "The Ordinances of Government", mainstream Sunni Muslims believed a man had to boast certain qualities in order to be a caliph, first and foremost, he needed to hail from the tribe of Quraish.
The book cites verses taken from the "hadith" – accounts of the sayings, actions or habits of the Prophet that are used as complementary teachings on all aspects of Muslim life. According to these verses, Muhammad stressed on various different occasions that only those from Quraish families were eligible to be caliphs. Some of the hadith cited are attributed to Imam Ahmad ibn Hanbal.
Sources including the "History of the Prophets and Kings" by Muhammad ibn Jarir Al-Tabari mention that migrants took advantage of this condition to boost their bid for power during the Saqifah Bani Sa'idah meeting. The gathering took place with the attendance of the Ansar (the Helpers) – Muslim converts who helped Muhammad and his followers when they arrived in Medina – right after the Prophet's death to choose a succeeding caliph.
Sunni: caliphs must be from the tribe of Quraish
Throughout the Rashidun and Umayyad caliphates, Quraish origins as prerequisite for being a caliph were never questioned; all those who ruled during the two epochs hailed unequivocally from the eminent tribe. However, upon the establishment of the Abbasid Caliphate in 749, non-Arab ethnicities began invading the ruling class.
During the early stages of their calling, Abbasids relied on winning over Persians who posed a revolutionary force driven by indignation towards the ruling Arabs. Some of them later became the real string-pullers of the Abbasid Caliphate, including Abu Muslim Al-Khurasani and the Barmakids.
The death of Caliph Harun Al-Rashid in 808 and the eruption of a civil war between the followers of both of his sons – Al-Amin and Al-Ma'mun – proved a turning point in the power structure. The rift between the brothers took on ethnic-national dimensions; the overwhelming majority of Arabs supported Al-Amin because his mother, Zubaidah, was an Arab, while most Persians backed Al-Ma'mun for his Persian mother, who was one of Al-Rashid's slaves.
After Al-Ma'mun won the war, he befriended the Persians, making Merv the seat from which to rule Khurasan. He remained there for a while before succumbing to pressure from the Abbasids and returning to Baghdad, the capital of his ancestors.