The Messenger of Allah ﷺ said, "When allegiance is pledged to two caliphs, kill the latter of the two."
قال رسول الله ﷺ: إذا بويع لخليفتين فاقتلوا الآخر منهما.
Muslim narrated it in the chapter on leadership (1853), from Wahb bin Baqiya Wasiti, who said, Khalid bin Abdullah narrated to us, from Jareeri, from Abu Nadra, from Abu Saeed Khudri, who mentioned it.