Sayyiduna Jarir (may Allah be pleased with him) said: I came to the Prophet (peace and blessings be upon him) while he (peace and blessings be upon him) was taking the pledge of the people. I said: "O Messenger of Allah, extend your hand so that I may pledge allegiance to you." He (peace and blessings be upon him) said: "How will you pledge allegiance to me?" Then he said: "I take your pledge that you will worship Allah, establish the prayer, pay the zakah, act sincerely towards the Muslim, and separate yourself from the polytheist."
Hadith Referenceالمعجم الكبير للطبراني / باب الجيم / 2305