It is narrated from Sayyiduna Abu Qatadah Al-Aslami (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "When any one of you enters the mosque, he should not sit down before performing two rak‘ahs (units of prayer)."
Hadith Referenceالسنن المأثورة / ما جاء في الجمع بين الصلاتين في المطر / 34
Hadith Takhrijصحیح بخاری، الصلاة، باب اذا دخل المسجد فليركع ركعتين، رقم: 444، صحیح مسلم، المساجد ومواضع الصلاة، باب استحباب تحية المسجد بركعتين، رقم: 714