The Qays–Yaman rivalry refers to the historical rivalries and feuds between the northern Arabian Qays tribes and the southern Arabian Yaman tribes. The conflict emerged among the tribes within the Umayyad Caliphate's army and administration in the 7th and 8th centuries. Membership in either faction was rooted in real or perceived genealogical origins of the tribes, which divided them into south Arabian descendants of Qahtan (Yaman) or north Arabian descendants of Adnan (Qays). Yamani tribes, including the Kalb, Ghassan, Balqayn, Amilah, Tanukh, Judham and Lakhm, were well-established in central and southern Syria in pre-Islamic times, while Qaysi tribes, such as the Sulaym, Kilab and Uqayl largely migrated to northern Syria and Upper Mesopotamia with the Muslim armies in the mid-7th century. The Qays–Yaman feud did not effectively take shape until after the reign of Caliph Mu'awiyah I, who, along with his Sufyanid descendants, were tied to the Kalb, the leading tribe of Yaman, through marriage and military dependence. When the last Sufyanid caliph died in 684, the Yaman resolved to ensure continued Umayyad rule to maintain their stately privileges, while the Qays backed Abdullah ibn Zubayr's bid for the caliphate. That year, the Yaman routed the Qays at the Battle of Marj Rahit, leading to years of revenge-driven, tit-for-tat raids known as ayyam (days) because the battles were typically day-long affairs. By 693, the raids had largely subsided as the Qays reconciled with the Umayyads and were incorporated into the state. The Umayyads attempted to balance the powers and privileges of both factions, but the rivalry smoldered until the third civil war (fitna) in the caliphate, in which the Yaman killed Caliph Walid II for his dependence on the Qays. Yamani opposition continued under Caliph Marwan II, and the Yaman ultimately defected to the Abbasids when the latter conquered the Umayyad realm in 750. The Yaman and Qays briefly joined forces against the Abbasids later that year, but were defeated.