Complex sentence: In 778, the Byzantine general Michael Lachanodrakon sacked the city, but it was immediately rebuilt by Caliph Al-Mahdi (r.775--785), who renamed it al-Mahdiya or al-Muhammadiya, although these names failed to catch on.
Split into simpler sentences: In 778, the Byzantine general Michael Lachanodrakon sacked the city, but it was immediately rebuilt by Caliph Al-Mahdi (r.775--785). Mahdi renamed it al-Mahdiya or al-Muhammadiya on this occasion, but these names failed to catch on.