Al-Ajurri preserves a report from the final days of Ali ibn Abi Talib, may Allah be pleased with him, in which Ali saw the Prophet Muhammad, peace and blessings be upon him, in a dream and spoke of the hardship he had faced from his people. The Prophet is then reported to have told him to supplicate, and Ali prayed that Allah replace his people for him with better people and replace him for them with someone worse than him. The account then moves directly to the morning prayer, when Ali went out and was attacked. A shorter form of the same story is also preserved by Ibn Abi al-Dunya and al-Lalaka'i.
The dream then turns from complaint to supplication. The Prophet, peace and blessings be upon him, is reported to have told Ali to pray. Ali asks Allah to replace his people for him with people better than them, and to replace him for them with someone worse than him. The report presents this prayer as part of the same final night and does not separate it from what follows in the morning.
When morning comes, the account moves to the prayer setting. Ali goes out and calls the people to the dawn prayer. The atmosphere changes suddenly from the quiet of the dream to the public setting of the mosque and the beginning of the day. It is at this point that the attack occurs, linking the dream and supplication directly with the final events of Ali’s life.
The force of the story lies in this close sequence. Ali first sees the Prophet in a dream and speaks of what he has endured. He is then told to supplicate and makes the prayer preserved in the report. Soon afterward he goes out for the morning prayer and is struck. The narrative therefore remembers the dream not as an isolated vision, but as an event immediately connected with the morning of the attack.
A shorter form of the same core story is also preserved by Ibn Abi al-Dunya and al-Lalaka'i. Al-Lalaka'i includes the report among accounts associated with the karamat of Ali ibn Abi Talib. Other later biographical and historical works likewise preserve the memory of the dream in connection with his final day, but the public story here follows the fuller sequence found in al-Ajurri.
Taken in that order, the account has a clear beginning and end: a dream of the Prophet, Ali’s complaint, the instruction to pray, his supplication, and then the dawn in which he went out and was attacked. These are the central scenes of the report as it has been preserved in the classical sources.
Conclusion
The report closes with Ali ibn Abi Talib, may Allah be pleased with him, going out for the dawn prayer after the dream and supplication, and then facing the attack that marked his final days.