…order you with five things which Allāh ordered me with: The Jamāʿah, hearing, obeying, ḥijrah (migration), and Jiḥād in the way of Allāh – the Mighty and Majestic. So whosoever separates from the Jamāʿah by a hand-span, throws off the yoke of Islām from his neck, unless he repents. And whosoever calls with the calls of the days of ignorance, then he is from the horde of the Hellfire.
From al-Ḥārith al-Ashʿarī (raḍī Allāhu ʿanhu) who said that the Messenger of Allāh ﷺ said:
“Indeed, Allāh – The Most High – ordered Yahyá Ibn Zakariyyā with five things; that he should act upon them and order the Children of Isrāʿīl to act upon them. ʿĪsá Ibn Maryam said to him, ‘Indeed Allāh ordered you with five things, that you act upon them, and that you order the Children of Isrāʿīl to act upon them. So either you order them, or I will order them.’ So Zakariyyā said, ‘If you precede me in that, I fear that I will be punished, or swallowed up by the earth.’ So he gathered the people in the Mosque of Jerusalem until it was filled, and the people sat upon its walls. He admonished them saying, ‘Indeed Allāh has ordered me with five things which I should act upon, and order you to act upon. The first thing is that you should worship Allāh and not associate anything along with Him in this worship. Verily one who worships anything along with Allāh is like a man who bought a slave with his own wealth – either gold or silver – and said, ‘This is my house and this is my work so give the wages to me. So the slave worked and gave wages to other than his owner. So which of you would be pleased for his slaves to be like that? But Allāh created you and provides for you, so do not associate anything in worship along with Him.
And I order you with prayer, and when you pray, then do not turn aside.
And I order you with fasting. And that is the like of a man, amongst a group of people, who had a small pouch containing musk. Each of them likes to smell it. And to Allāh, the fasting person is better than the smell of musk.
And I order you with Sadaqah (charity). For its like is that of a man taken prisoner by the enemy, so they will take a hold of him and tie his hand to his neck, so he will say, ‘Will you not allow me to ransom myself for you?’ So he gives them small and large amounts to escape from them.
And I order you to make mention and remember Allāh a lot. And the like of this is a man being chased by the enemy, who are hastening after him. So he comes to a protected fortress and enters into its protection. Likewise is the case for the servant. For he does not protect himself from Shayṭān except by the remembrance of Allāh – the Mighty and Majestic.”
The Messenger of Allāh ﷺ said: “I order you with five things which Allāh ordered me with: The Jamāʿah,1 hearing, obeying, ḥijrah (migration), and Jihād in the way of Allāh – the Mighty and Majestic. So whosoever separates from the Jamāʿah by a hand-span, throws off the yoke of Islām from his neck unless he repents. And whosoever calls with the calls of the days of ignorance, then he is from the horde of the Hellfire.” It was said, “Even if he fasts and prays?” He said, “Even if he fasts and prays. So call with the Call of Allāh which Allāh gave: The Muslims, the Believers, Worshippers of Allāh.”2
 At-Teebee said – as occurs in Tuhfatul-Aḥwadhī Sharḥ Sunanut-Tirmidthī (8/162): ‘‘What is meant by ‘the Jamāʿah’ is the Companions, the Tābi’īn, and the generation after the Tābi’īn – the Salaf al-Ṣāliḥ (Pious Predecessors): That is, ‘I order you to cling to their guidance, and their way, and associate with them.’’’
 Ṣaḥīḥ: Related by at-Tirmidthī (no. 2863-2964), al-Tiyālisī (no. 1161-1162) and others. And its chain of narration is authentic.