Praise be to Allah.
The Prophet(PBUH) mention the murder of Ali, and it happened the way the Prophet explain it. Even though, the Prophet had died before that time.
As Narrated by Ammar Ibn Yasir, who said: The Messenger of Allah (Peace and Blessings of Allah be upon him) said to Ali when he was made in charge of the Battle of Al-Ushairah, “O Abu Turab – because of what he saw upon him from Turab (soil) – shall I not inform you of the two worst men of the people?”
We said, “Indeed, O Messenger of Allah.” He replied, “Uhaimir Thamood, the one who slew the she-camel (see Soorah Shams) and the one who will hit you on this, O Ali – (he pointed to) the top of his head – until this is wet from it,” (he pointed to) his beard (i.e. until his beard will be full of blood).
Zaid Ibn Wahb narrated that: The leader of the Khawarij came to Ali and said to him, “Fear
Allah because you are going to die.” He replied, “No, by the One Who cleaves the grain and the One Who created human being, but I am going to be murdered from a blow to this which will dye this – and he pointed to his beard – is a fixed covenant and a decreed decree and he has failed who invents (such falsehood).”
It is renowned from Ali that when Abdur Rahman Ibn Muljam Al-Khariji stabbed him while he was exiting for the morning prayer at the door, Ali remained alive for two days since the stabbing and Ibn Muljam was held.
Ali nominated his son Al-Hasan for being the Caliph as shall be mentioned and commanded him to lead the armies and said to him, “Ali doesn’t flow like the river.”
When he died, Abdur Rahman was killed by means of Qawad (punishment for murder) and it is mentioned that he was killed by means of Hadd (punishment). However, Al-Hasan Ibn Ali led the armies and went to Mu‘awiyah.
This was taken from Al-Bidayah wan-Nihayah
And Allah (SWT) knows best.