Sayyiduna Jarir bin Abdullah (may Allah be pleased with him) says: I came to the Prophet (peace and blessings be upon him) while he was taking the pledge of allegiance from the people. I said: O Prophet of Allah! Stretch out your hand so that I may pledge allegiance to you, and also lay down for me whatever conditions you consider appropriate for me. So he (peace and blessings be upon him) said: "I take your pledge on condition that you worship Allah, establish the prayer, pay the zakah, sincerely wish well for the believer, and separate yourself from the polytheist."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السير / 17751