The port fell to a Sassanid invasion in the 3rd century CE, under the rule of Shapur I, while conversion to Islam occurred during the 7th century. Muscat's importance as a trading port continued to grow in the centuries that followed, under the influence of the Azd dynasty, a local tribe. The establishment of the First Imamate in the 9th century was the first step in consolidating disparate Omani tribal factions under the banner of an Ibadi state. However, tribal skirmishes continued, allowing the Abbasids of Baghdad to conquer Oman. The Abbasids occupied the region until the 11th century, when they were driven out by the local Yahmad tribe. Power over Oman shifted from the Yahmad tribe to the Azdi Nabahinah clan, during whose rule, the people of coastal ports such as Muscat prospered from maritime trade and close alliances with the Indian subcontinent, at the cost of the alienation of the people of the interior of Oman.