Muslim Arabs conquered Omani territory around 630 AD with their prophet companion Amr ibn al-As and made it part of the Umayyad and Abbasid caliphate. This caliphate ruled Oman for a long time from Baghdad and Damascus. This marks the birth of Islam in Oman. Several decades later, the Islamic faith of the Ibadites, who founded independent imams in the hinterland around 900 AD, was formed. After prolonged power struggles, the rule of imams lost its influence on the Nabhani dynasty, which Oman could reunite around 1180 after Christ. The Nabhani made Bahla their capital but were constantly threatened by Persian invaders. This time is barely documented, but there were always variations in the size of the territory. At the end of this dynasty, the Persians took over the coastal regions again, before the Portuguese conquered Muscat in 1507.