Abu Ja'far Muhammad ibn Ahmad al-Baghdadi (Arabic: أبو جعفر محمد بن أحمد البغدادي) was an agent and senior official of the early Fatimid Caliphate.
As his indicates, Abu Ja'far Muhammad hailed from Baghdad, the capital of the Abbasid Caliphate. For unknown reasons, likely related to his pro-Shia views, he was persecuted by the vizier Ali ibn Isa ibn al-Jarrah and had to leave Iraq, making his way west. At Sijilmasa, where there was a sizeable Baghdadi colony, he met the Isma'ili leader and future founder of the Fatimid Caliphate, Abdallah al-Mahdi Billah.
Al-Baghdadi quickly found favour with al-Mahdi with his knowledge and ability, who employed him as advisor and secretary. He then spent some time in Cordoba, the capital of al-Andalus, where he became well known in the local literary circles; his true role, however, was as a spy, missionary and agent for al-Mahdi.
He returned from Cordoba and rejoined his master sometime before the latter was proclaimed caliph in 909, and became his chief secretary upon the death of the first holder of the post, Abu'l-Yusr al-Riyadi in January 911. In this capacity he headed the caliphal chancery, as well as the postal service, which also served as an intelligence service. In this capacity he was "the perfect secretary" (Dachraoui), and quickly became the most influential member of al-Mahdi's court.
He continued in office after al-Mahdi's death in 934, and likely until his death, serving three Fatimid caliphs: al-Mahdi, al-Qa'im, and al-Mansur . The date of his death is unknown. His successor was the slave Jawhar al-Siqilli, who would go on to serve as a distinguished military commander and conquer Egypt for the Fatimids.