Complex sentence: Al-Hasan meanwhile allied with Hasan, but when Ibn Muhtaj took Ray from the Buyids in 945, he recognized Samanid authority.
Split into simpler sentences: Al-Hasan meanwhile allied with Hasan. In 945, Ibn Muhtaj took Ray from the Buyids, and made al-Hasan recognize Samanid authority.