In 661 CE, after Ali's murder, Hasan ibn Ali attained to the caliphate. There was a military conflict between Ahl al-Bayt and Muawiya ibn Abu Sufyan (see Battle of Siffin); and to avoid the agonies of a further civil war, Hasan signed the Hasan–Muawiya treaty with Muawiyah. According to the treaty, Hasan ceded the caliphate to Muawiyah but the latter could name no successor during his reign; instead, he was to let the Islamic world choose its successor afterward.
Muawiyah was the governor of the Levant region of Arabia at the time (modern day Syria, Lebanon, Jordan, Palestine). He had refused Ali's repeated demands for allegiance, when Ali was elected as the fourth Caliph, and was therefore in conflict with him. However, when Ali was assassinated and people gave allegiance to Hasan, Muawiyah prepared to attack Hasan. As a result there were repeated skirmishes between the armies of Hasan and Muawiyah with no conclusive outcome.
Muawiyah who had already started negotiations with Hasan, sent high-level envoys, while committing himself in a witnessed letter to appoint Hasan his successor and give him whatever he wished. Hasan accepted the offer in principle and sent Amr ibn Salima al-Hamdani al-Arhabl and his own brother-in-law Muhammad ibn al-Ash'ath back to Muawiyah as his negotiators, together with the envoys of the latter. Muawiyah then wrote a letter saying that he was making peace with Hasan on the basis that Hasan would inherit the reign after him. He swore that he would not seek to harm him; and that he would give him 1,000,000 dirhams from the treasury (Bayt al-mal) annually, along with the land tax of Fasa and Darabjird; to which Hasan was to send his own tax agents to collect it. The letter was witnessed by the four envoys and dated in August 661.
When al-Hasan read the letter he commented: "He is trying to appeal to my greed for a matter which, if I desired it, I would not surrender to him." Then he sent Abd Allah ibn al-Harith, whose mother Hind was Muawiyah's sister, to Muawiyah, instructing him: "Go to your uncle and tell him: If you grant safety to the people I shall pledge allegiance to you." After which, Mu'awiyah gave him a blank paper with his seal at the bottom, inviting Hasan to write on it whatever he desired.
According to Jafri, historians like Ya'qubi and Al-Masudi do not mention the terms of peace treaty at all. Other historians such as Dinawari, Ibn Abd al-Barr and Ibn al-Athir records different accounts of the conditions. And the timing of the blank sheet sent by Muawiyah to Hasan was confusing in Tabari's account. The most comprehensive account, which explains the different ambiguous accounts of other sources, according to Jafri, is given by Ahmad ibn A'tham, which must have taken it from al-Mada'ini. Madelung's view is close to that of Jafri when he stipulates that Hasan surrendered the reign over the Muslims to Muawiya on the basis that "he act in accordance with the Book of God, the Sunnah of His Prophet and the conduct of the righteous caliphs. Muawiyah should not be entitled to appoint his successor but that there should be an electoral council (Shura); the people would be safe, wherever they were, with respect to their person, their property and their offspring; Muawiyah would not seek any wrong against Hasan secretly or openly, and would not intimidate any of his companions." The letter was testified by Abd Allah ibn al-Harith, and Amr ibn Salima and transmitted by them to Muawiyah for him to take recognition of its contents and to confirm his acceptance. Hasan, thus, surrendered his control of Iraq in Rabi II 41/August 661 after a reign of seven months.
Narrated by Al-Hasan Al-Basri:
|“||By Allah, Al-Hasan bin Ali led large battalions like mountains against Muawiya. Amr bin Al-As said (to Muawiya), "I surely see battalions which will not turn back before killing their opponents." Muawiya who was really the best of the two men said to him, "O 'Amr! If these killed those and those killed these, who would be left with me for the jobs of the public, who would be left with me for their women, who would be left with me for their children?" Then Muawiya sent two Quraishi men from the tribe of 'Abd-i-Shams called 'Abdur Rahman bin Sumura and Abdullah bin 'Amir bin Kuraiz to Al-Hasan saying to them, "Go to this man (i.e. Al-Hasan) and negotiate peace with him and talk and appeal to him." So, they went to Al-Hasan and talked and appealed to him to accept peace. Al-Hasan said, "We, the offspring of 'Abdul Muttalib, have got wealth and people have indulged in killing and corruption (and money only will appease them)." They said to Al-Hasan, "Muawiya offers you so and so, and appeals to you and entreats you to accept peace." Al-Hasan said to them, "But who will be responsible for what you have said?" They said, "We will be responsible for it." So, what-ever Al-Hasan asked they said, "We will be responsible for it for you." So, Al-Hasan concluded a peace treaty with Muawiya. Al-Hasan (Al-Basri) said: I heard Abu Bakr saying, "I saw Allah's Apostle on the pulpit and Al-Hasan bin 'Ali was by his side. The Prophet was looking once at the people and once at Al-Hasan bin 'Ali saying, 'This son of mine is a Saiyid (i.e. a noble) and may Allah make peace between two big groups of Muslims through him."||”|
|“||al Hasan had already made peace with Muawiyah on condition that he concede to him what was in his own treasury plus the revenue of Darabjird and that 'Ali not be reviled in his hearing.||”|
The main condition Hasan ibn Ali imposed on Muawiya for handing over power was to be just to the people and keep them safe and secure.  Following is the extract of the treaty between Imam Hassan and Muawiya:
- Authority will be handed to Muawiya provided that he should act according to the Book of Allah, the Sunna of the Prophet, and the behavior of the righteous Caliphs
- Authority should be for Imam Hassan after Muawiya, and if an accident occurs, authority should go to Imam Hussain, Muawiya has no right to entrust authority to anyone
- Muawiya should abandon cursing the Commander of the faithful (Imam Ali) and the practice of using the qunut in the salat against him, Muawiya should also not mention Imam Ali unless in a good manner.
- He (Muawiya) should exclude what is in the treasury of Kufa, that is five million (dirhams). So handing over authority does not include it (i.e., this sum of money). Muawiya should send al-Husayn one million dirhams a year, he should prefer the children of Hashim (banu Hashim) in giving and gifts to the banu Abd Shams, and should divide one million (dirhams) among the sons of those who were killed with the Commander of the faithful at the Battle of the Camel and the Battle of Siffin, and should spend that from the taxes of Dar Abjard.
- The people should be safe wherever they are in the earth of Allah. Muawiya should give security to all races. The companions of Imam Ali should be given security wherever they are. Muawiya should not seek a calamity secretly or openly for Imam Hassan, nor for Imam Hussein, nor for any of the Prophet’s Ahlul Bayt.
After the peace treaty, Hasan received Mu'awiya's letter asking him to counter khariji threat. He sent him the following reply:
|“||"O Mu'awiya! You have appointed Hasan bin Ali to go like one of your officers and to ward off a rebellious Khariji. I, Hasan bin Ali, have retired, in the interest of the Muslims, from the caliphate, which is my right. If I had wished to fight against one of the people of the Qibla i.e. with a Muslim, whoever he might be, and to which ever sect he might belong, I would have fought against you in the first instance".||”|
Hasan retired from the caliphate and thus safeguarded the blood of the Muslims and the strength of Islam, and prevented the external and internal enemies from taking undue advantage of the situation. One of the conditions of the Peace Treaty between Imam Hasan and Muawiya reads that, "Hasan bin Ali makes Peace on the condition that he will not be under an obligation to call Muawiya, the Commander of the Faithful". It is claimed that Muawiya violated all the conditions of the peace treaty and did not take care of the following five items of the treaty and committed horrible crimes against the Shias of Ali:
- He did not act according to the Book of Allah, the Sunna (i.e., practices) of His Apostle, and the practices (Sira) of the Orthodox Caliphs,
- He did not leave the authority after him to the Consultative Committee or to the Owner of the right (i.e., al-Hasan),
- He did not refrain from cursing Ali, he increased cursing Ali to the extent that he ordered his orators to curse him everywhere
- He did not give (al-Hasan) the land taxes,
- He did not give security to Ali's Shias and companions
- Donaldson, Dwight M. (1933). The Shi'ite Religion: A History of Islam in Persia and Irak. BURLEIGH PRESS. pp. 66–78.
- Jafri, Syed Husain Mohammad (2002). The Origins and Early Development of Shi’a Islam; Chapter 6. Oxford University Press. ISBN 978-0195793871.
- Shaykh Radi Aal-Yasin; Translated by Jasim al-Rasheed. Sulh al-Hasan (The Peace Treaty of al-Hasan (a)). Qum: Ansariyan Publications. Retrieved 30 December 2013.
- "Alī ibn Abu Talib". Encyclopædia Iranica. Retrieved 2010-12-16.
- Momen, Moojan (1985). An Introduction to Shi'i Islam. Yale University Press. p. 14,26,27. ISBN 978-0-300-03531-5.
- Madelung 1997, p. 322
- Madelung, Wilferd (2003). ḤASAN B. ʿALI B. ABI ṬĀLEB. Encyclopedia Iranica.
- Madelung 1997, pp. 322–323
- "Sahih Al Bukhari, Volume 3, Book 49 (Peacemaking), Number 867". Sahih-bukhari.com. Retrieved 2013-12-30.
- History of the Prophets and Kings, Between Civil Wars: The Caliphate of Muawiyah, Section: The Rendering of Allegiance to al Hasan b. Ali
- The Succession to Muhammad: A Study of the Early Caliphate By Wilferd Madelung Page 232 
- al-Hadid, Ibn Abu. Sharh Nahj al-Balagha, vol. 4. p. 6.
- Ibn Aqil. al-Nasaih al-Kafiya. p. 156.
- Al-Majlisi. Bihar al-Anwar, vol. 10. p. 115.
- al-Suyūṭī, Jalāl al-Dīn al-Khuḍayrī. History of the Caliphs:Tarikh Al-Khulafa. CreateSpace Independent Publishing Platform (June 3, 2014). p. 194. ISBN 978-1499770056.
- =Ibn Kathir. al-Bidaya wa alNahaya, vol. 8. p. 41.
- al-Asqalani, Ahmad Shahab al-Din. al-Isaba fi Tamiiz al-Sahaba, vol. 2. pp. 12, 13.
- al-Dinawari, Ibn Qutayba. al-Imama wa al-Siyasa. p. 150.
- Wajdi, Farid. Dairat al-Marif al-Islamiya, vol. 3. p. 443.
- Ibn al-Muhanna. Umdat al-Talib. p. 52.
- Ibn Abu al-Hadid. Sharh Nahj al-Balagha, vol. 4. p. 8.
- Ibn al-Sabbagh. al-Fusw al Muhimma.
- al-Amili, Muhsin al-Amin. A'yan al-Shia, vol. 4. p. 43.
- al-Isfahani, Abu al-Faraj. Maqatil al-Talibiyyin. p. 26.
- al Hadid, Ibn Abu. Sharh Nahj al-Balagha, vol. 4. p. 15.
- al-Dinawari, Ibn Qutayba. al-Imama wa al-Siyasa. p. 200.
- al-Tabarī. The History of al-Tabari Vol. 6. SUNY Press (August 1, 1987). p. 92. ISBN 978-0887067075.
- Ibn Babawayh. Ilal al-Sharaiya. p. 81.
- Ibn Kathir. al-Bidaya wa al-Nihaya, vol. 8. p. 14.
- al-Tabarī. The History of al-Tabari Vol. 6. SUNY Press (August 1, 1987). p. 97. ISBN 978-0887067075.
- Ibn al-Aft. al-Kamil fi al-Tarikh, vol. 3. p. 166.
- Ibn Aqil. al-Nasaih al-Kafiya. p. 115.
- Ayati, Dr. Ibrahim. "Eight". A Probe into the History of Ashura'. Karachi - The Islamic Republic of Pakistan: Islamic Seminary Publications. Retrieved 30 December 2013.