Imam Ali's (AS) generals, who stopped the battle to negotiate with Mu'awiya, did not pick the right person for the negotiation. They unyieldingly refused to accept Imam Ali's choice, instead they picked Kufa's Governor, Abu-Musa Ash'ari, an incompetent Governor who had been previously dismissed from office by Imam Ali. Mu'awiya appointed Amr Ibnil Aas, a shrewd and cunning man, to be his representative in the negotiation. Negotiation between the two sides did not take place for about one year.
When the two negotiators came face to face, it was clear that Ash'ari's capability was no match for his opponent Ibnil Aas. In the negotiations, Ash'ari proposed that, both Mu'awiya and Imam Ali (AS) were to abdicate and to let the people hold election for the Khilaafah. Amr Ibnil Aas, a deceptive man at best, quickly agreed to Ash'ari's proposal and asked Ash'ari to first announce the agreement.
Ash'ari stood up and announced, "O people, we have agreed not to consider Ali or Mu'awiya for Khilaafah. You may choose or elect whomever you think is fit." The cunning Amr Ibnil Aas stood up next to say, "O people! I won't consider Ali for the Khilaafah. But Mu'awiya, in my opinion, is the person for that office!" Upon hearing this (and feeling deceived), the people screamed disapprovingly, an uproar was the result.
Imam Ali's (AS) camp was in shock, they were double-crossed, deceived and lied to, they felt deeply cut. Amr's double crossing and deception was simply beyond their imagination. They left the place bewildered and utterly disappointed. Because of this a large group of Imam Ali's supporters defected to form a separate group called Kharijies, meaning the Outsiders.
The Khariji became fanatically opposed to Imam Ali and Mu'awiya. Some of their members met secretly in Mecca and drew a plan to assassinate Ali (AS) in Kufa, Mu'awiya in Syria, and Amr Ibnil Aas in Egypt.
Three fanatics took the responsibility, they were to attack their victims in the morning, the same day, as the would-be victims were going to the mosque to lead the morning salat. Ibn Muljim attacked and fatally wounded Imam Ali (AS), whereas Mu'awiya escaped with a light wound of his buttock. Amr Ibnil Aas was ill that day and his replacement was killed by the Khariji.
Imam Ali (AS), in wounded condition, conferred the Imamah and the reign of the Islamic nation to his 37 years old son
source : sibtayn