The Prophet ﷺ said, "Differ from the polytheists. Let your beards grow and trim your moustaches closely."
عن النبي ﷺ قال: خالفوا المشركين، وفروا اللحى، وأحفوا الشوارب.
Bukhari related it in the Book of Clothing (5892), and Muslim in the Book of Purification (54:259), both from the hadith of Yazid bin Zuray, who said, Umar bin Muhammad bin Zayd narrated to us, from Nafi, from Ibn Umar, and he related it. The wording given is Bukhari's. Muslim's wording is, "Differ from the polytheists, trim your mustaches closely, and let your beards grow full." Bukhari said, Ibn Umar, when he performed Hajj or Umrah, would grasp his beard and cut off whatever exceeded his grip.Malik related it in the Book of Hajj (200) from Nafi, that Abdullah bin Umar, when he shaved his head during Hajj or Umrah, would trim from his beard and mustache.