Wali al-Ahd (Arabic: ولي العهد|Walī al-ʿAhd) is the Arabic and Islamic term for a designated heir of a ruler, or crown prince.
The title emerged in the early caliphates, and can be traced to at least . The title itself is ambiguous, as the term can mean both 'possessor of' or 'successor to', and the exact scope of, 'covenant, testament', is left unclear: it can be interpreted as the covenant of God with humanity as a whole, of the previous caliph, or of the Muslim community. The Umayyad caliphs (661–750) certainly favoured a more absolutist interpretation, by which they claimed a mandate deriving directly from God, via their position as heirs to Muhammad. By the 740s, the term (Arabic: ولي عهد المسلمين,), or even the variant ('successor to the covenant of the Muslim men and Muslim women') appears in use, either in the sense of the Muslim community pledging allegiance to the heir-designate, or the heir being the successor to the covenant with the Muslim community. The term was established as the usual title of the caliphal heir-apparent by the time of the first Abbasid caliphs (750–1258).
The origin of the practice has pre-Islamic roots, among the choice of successor in the Arab tribes. In the Islamic period, this ancient practice was given new legitimacy when the first caliph, Abu Bakr, nominated his successor, Caliph Umar. Umar in turn later nominated a group of prominent Muslims to choose one of their number as his successor. The choice of heir was set on a hereditary basis by the first Umayyad caliph, Mu'awiya I, who chose his own son, Yazid I. The hereditary principle prevailed thereafter, although sometimes a brother could be chosen instead, or multiple sons be nominated as first and second heir; though usually the latter practice led to succession disputes. In Sunni jurisprudence, the choice of successor and the act of designation is the absolute prerogative of the caliph or ruler; the oath of allegiance offered to the new heir confirmed his status, but was not a prerequisite for his legitimacy.
This designation was made manifest through a testament . In the Umayyad period, this was a relatively informal matter, and often the designation of an heir-apparent was made public only after the incumbent caliph's death. In the Abbasid period, this became a formalized and increasingly elaborate affair, deserving of a special ceremony, in which the new heir-designate also received the pledge of allegiance from the assembled court. After that, he received his own insignia and a regnal name, by which he was named in the Friday prayer, on banners and on coinage, alongside the caliph. If still underage, the heir-designate received a tutor, and he was later sent to govern a province in order to gain experience. In the early Abbasid period, heirs served as regents during the caliphs' absence from Baghdad.
The title was used by several medieval Islamic states, such as the Fatimid Caliphate, the Seljuk Empire, the Buyid dynasty, Mamluk Egypt, and in al-Andalus. Uniquely, in 1013 the Fatimid caliph al-Hakim, who also combined in his person the position of imam of the Isma'ili branch of Islam, separated his succession in two: his cousin Abd al-Rahim ibn Ilyas was designated and heir to the caliphate, while another cousin, Abu Hashim al-Abbas ibn Shu'ayb, was designated heir to the Isma'ili imamate, with the title of , 'successor to the covenant of the faithful', thereby separating the government of the Fatimid state from the hitherto state religion of Isma'ilism. Following al-Hakim's murder in 1021, both heirs were sidelined and the succession to both offices united in the person of al-Hakim's son, al-Zahir.
In modern times, the term has been revived for the crown princes of several states, such as the Qajar and Pahlavi Iran, Saudi Arabia, Jordan, Qatar and Bahrein.