As for the Khalifat of 'Ali (r.a.a.), it came about as a result of the general agreement of the community, and by the consensus of the Companions.
This view of the matter is borne out by the traditional report of Abu Abdillah bin Batta, who attributes the following account to Muhammad ibn al-Hanafiyya:
I was in the company of Hazrat 'Ali bin Abu Tāleb while 'Uthman bin Affan was under seige. Then a man came along and told us: 'The Commander of the Believers was just killed just a little while ago.' Ali (r.a.a.) sprang to his feet at once, so I grabbed him and held him by the waist, for fear that he might do something rash, but he cried: "Let go of me, you wretch!" Then 'Ali went to the palace, where he found that 'Uthman had indeed been slain, so he made his way to his won house, went inside, and locked the door.He was therefore a rightful leader (Imam) from that time on, until the moment when he was martyred, contrary to what is said by the Khawarij, for they maintain that he never was a legitimate leader. May they be doomed to perdition!
The people came after him, and started hammering on his door. As soon as they were admitted inside, they said: 'Uthman has ben killed, and the people cannot manage without a Khalif. There is no one, as far as we know, who is better qualified forthe job than you are.' But 'Ali responded to this by saying to them: 'You do not really want me, for I can serve you better as a minister (wazeer) than as an Amir.'
Still the people insisted: 'We know of no one who is better qualified for the job than you are.' So he said: 'Very well, if you insist on leaving me no choice. In any case, the fact that homage has been paid to me will not be a secret for long, but let me go out to the masjid, so that all those who wish to pledge the allegiance to me may do so there.' 'He then left his house and went to the masjid, where the people came and pledged their allegiance to him."
As for the battle he fought against Talha, az-Zubayr, A'isha and Mu'awiya, the emphatically stated opinion of Hazrat Imam Ahmad bin Hanbal is that we should adopt an attitude of strict neutrality toward this incident, and indeed toward all the conflict, contention and controversy that flared up amongst them, because Allahu Ta'ala will remove it all from their midst on the Day of Resurrection. As He says in the Holy Qur'an:
And Well shall strip away whatever rancor may be in their breasts. As brothers they shall be upon couches set face to face. [Holy Qur'an 15:47]Besides, from his own perspective, 'Ali (r.a.a.) was in the right in doing battle with them, because he was firmly convinced of the legitimate character of his leadership. As we have just explained, he had in fact been appointed to the Imamate and Khalifat by the general agreement of the group of Sahabi who had functioned as an electoral college. Anyone who decided to back out of this at a later stage, and who actually took arms against him, would of course be a rebel, a person in revolt against the leader, so the leader would be quite justified in fighting him.
From the standpoint of those on the other side, notably Mu'awiya, Talha, and Az-Zubayr, the battle against 'Ali was fought because they needed to avenge the death of 'Uthman, the rightful Khalif who had been wrongfully slain, and the men who killed him were soldiers in the army of Hazrat Ali.
Thus everyone involved could come up with a credible justification. As far as we ourselves are concerned, therefore, the best course is to adopt an attitude of strict neutrality toward this whole issue, and to leave the verdict in their case to Allahu Ta'ala, for He is the Wisest of judges and the Best of deciders. Our attention should be focussed on the faults in our own selves, on the purification of our hearts from the root causes of sinful behavior, and of our outer beings from thngs that pose serious threats of our welfare.