The Abbasid Caliphate under the Buyids was Iraq with Baghdad in 945–1055, when the caliphs kept only religious authority. In 945 the Buyid emir Ahmad (Mu'izz al-Dawla) entered Baghdad, took the title of amir al-umara and began appointing and deposing caliphs himself, even though the Buyids were Shi'a and the caliphs Sunni. The tutelage ended in 1055, when the Seljuk Tughril Beg occupied Baghdad.