The Messenger of Allah ﷺ said, "Islam is built upon five pillars: the testimony that there is no god but Allah and that Muhammad is the Messenger of Allah, establishing the prayer, giving the zakat, performing the pilgrimage, and fasting Ramadan."
قال رسول ﷺ: بني الإسلام على خمس: شهادة أن لا إله إلا الله وأن محمدا رسول الله، وإقام الصلاة، وإيتاء الزكاة، والحج، وصوم رمضان.
Bukhari narrated it in Faith (8), and Muslim in Faith (16/22), both from the hadith of Hanzala bin Abu Sufyan, who said, "I heard Ikrima bin Khalid, from Ibn Umar," then he related the hadith. The wording given here is Bukhari's.In Muslim's version, Hanzala said, "I heard Ikrima bin Khalid narrating to Tawus that a man said to Abdullah bin Umar, 'Will you not go out to fight?' He replied, 'I heard the Messenger of Allah ﷺ'" then he related the hadith.The fuller account is what Bukhari narrated in tafsir (4513), from Nafi, from Ibn Umar. Two men came to him during the strife of Ibn Zubayr and said, "The people have gone astray, and you are the son of Umar and a companion of the Prophet ﷺ, so what keeps you from going out?" He said, "What keeps me is that Allah has forbidden the blood of my brother." They said, "Did Allah not say, "Fight them until there is no strife" [Baqarah 2:193]?" He said, "We fought until there was no more strife, and religion belonged to Allah. But you want to fight until there is strife, and religion belongs to someone other than Allah."Uthman bin Salih added, from Ibn Wahb, who said, "So-and-so and Haywa bin Shurayh informed me, from Bakr bin Amr Maafiri, that Bukayr bin Abdullah told him, from Nafi, that a man came to Ibn Umar and said, 'Abu Abdul-Rahman, what leads you to go on Hajj one year and perform Umrah another year, while forsaking jihad in the path of Allah , when you know how much Allah has encouraged it?'He said, 'Nephew, Islam is built upon five pillars, faith in Allah and His Messenger, the five daily prayers, fasting Ramadan, paying zakat, and pilgrimage to the House.'The man said, 'Abu Abdul-Rahman, have you not heard what Allah mentions in His Book, "And if two parties among the believers fight each other, then make peace between them. But if one of them oppresses the other, then fight the one that oppresses until it returns to the command of Allah" [Hujurat 49:9], and "Fight them until there is no strife" [Baqarah 2:193]?'He said, 'We did that in the time of the Messenger of Allah ﷺ, when Islam was few in number, and a man would be persecuted for his religion, either killed or tortured, until Islam grew numerous and there was no more strife.'The man asked, 'What do you say about Ali and Uthman?'He said, 'As for Uthman, Allah pardoned him, but you disliked that He should pardon him. As for Ali, he was the cousin of the Messenger of Allah ﷺ and his son-in-law,' and he pointed with his hand and said, 'This is his house, right there before you.'"