In 377/987-8 a band of them arrived in eighteen boats and freed Maimun, but then many of them were massacred by the people of al-Bab and the rest departed, while Maimun fortified himself in the citadel of the town with a guard of Russians. In 379/989-90 a popular preacher from Gilan, Muhammad al-Tuzi, found an eager audience in al-Bab and gained complete control over the tow^n. Maimun was at first swayed by his preaching, but later resisted his demands. He was besieged in the citadel by the people supporting the preacher and was forced to leave for Tabarsaran (380/990-1).
The preacher invited the Sharvan-Shah Muhammad b. Ahmad to take over the rule of al-Bab. Muhammad, who had succeeded his father in 370/981, pursued a policy of expansion taking possession of the town of Qabala from its ruler c Abd al-Barr b. 'Anbasa (371/981) and of Barda'a (c. 372/982). He now came readily to al-Bab, but shortly after his arrival was wounded by a slave of Maimun who struck him with a battle-axe. While he returned to Sharvan, Maimun reoccupied al-Bab. The Hashimid in 381/991 was once more expelled by the people, who recalled the Sharvan-Shah.
The latter soon departed again, leaving a garrison in the citadel. Maimun reconquered al-Bab in 382/998-9 and in the following year also took the citadel. In 385/995 the people of the region of al-Karakh, located in a strategic position on the route from al-Bab to central Daghistan, were converted to Islam by him. Maimun died in 387/997. His brother Muhammad, who succeeded him, was murdered after ten months by a ghulam of Maimun. Four months later (388/998) Maimun's son alLashkari acceded to the rule. The feud with Sharvan flared up again with new vigour.
In Sharvan Muhammad b. Ahmad had been succeeded by his brother Yazld. In consequence to the earlier conquest of Qabala, the Sharvanian army in 382/992 met the army of Shakkl near the town and suffered severe losses. In 389/999 Yazid took the castle of Gurzul from 'Abd al-Barr, the former lord of Qabala. Then he fought the Hashimid al-Lashkarl in a dispute over an estate. Al-Lashkari won an initial victory and seized the estate, but later the Sharvan-Shah routed him at Shabaran and captured his brother Abu Nasr. When al-Lashkarl died in 392/1002, the people of al-Bab requested him to release Abu Nasr. Yazid, intent on restoring the Sharvanian authority over al-Bab, proposed that Abu Nasr should marry his daughter and demanded the surrender of the citadel of al-Bab to himself.
When the people of al-Bab refused this demand, he killed Abu Nasr and fought his brother al-Mansur, to whom the people of al-Bab swore allegiance in 393/1003. The war between Sharvan and al-Bab dragged on with changing fortune until the people of al-Bab revolted and expelled al-Mansur in 410/1019- 20 and surrendered the town to the Sharvan-Shah, who put a garrison into the citadel. Al-Mansur recovered town and citadel in 412/1021-2 with the support of the lord of al-Sarir and fought an inconclusive battle with the Sharvanians at Shabaran. In 414/102 3-4 he was again driven out by the people, who surrendered the town to the SharvanShah, but he reconquered it in 415/1024.
The feud was temporaril interrupted when the Sharvan-Shah in 416/1025 during his absence from his capital al-Yazidiyya was faced with a rebellion of his son Anushirvan there. Anushirvan soon lost most of his supporters and fled as his father approached the capital. He was captured and starved to death in prison. Yazid died in 418/1027 and was succeeded by another son, Manuchihr.