al-Afdal Shahanshah (Arabic: الأفضل شاهنشاه, translit. al-Afḍal Shāhanshāh; Latin: Lavendalius/Elafdalio; 1066 – December 11, 1121), born Abu al-Qasim Shahanshah ibn Badr al-Jamali and surnamed al-Malik al-Afdal ("the excellent prince"), was a vizier of the Fatimid caliphs of Egypt.
He was born in Acre, the son of Badr al-Jamali, an Armenian mamluk who became Muslim. Badr was vizier for the Fatimids in Cairo from 1074 until his death in 1094, when al-Afdal succeeded him. Caliph Ma'ad al-Mustansir Billah died soon afterwards, and al-Afdal appointed as caliph al-Musta'li, a child, instead of al-Mustali's much older brother Nizar. Nizar revolted and was defeated in 1095; his supporters, led by Hassan-i-Sabah, fled east, where Hassan established the Ismaili community, sometimes erroneously called the Hashshashin, or Assassins.
At this time Fatimid power in Palestine had been reduced by the arrival of the Seljuk Turks. In 1097 he captured Tyre from the Seljuks, and in 1098 he took Jerusalem, expelling its Ortoqid governor Ilghazi in place of a Fatimid. Al-Afdal restored most of Palestine to Fatimid control, at least temporarily.