Reference: Silsilah Kitaab ad-Da ‘wah (1), al-Fataawa – Volume 1, Page 52
Question: What is the ruling of [performing] the tahiyyatul-masjid (two rak’ah Sunnah prayer upon entering the masjid and before sitting down) just after the adhaan of [the] Maghrib [prayer] and before the [Maghrib] prayer [itself, considering] whilst the time period between the adhaan and the iqaamah is short; And also what is the ruling of [performing] the voluntary prayer before the Maghrib prayer?
Response: The tahiyyatul-masjid [prayer] is a recommended Sunnah [to be done] at all times, even during the prohibited times (between after the Fajr prayer and sunrise and between after the ‘Asr prayer until Maghrib) according to the correct of the two opinions of the scholars, based upon the saying of the Prophet (sal-Allaahu ‘alayhi wa sallam):
«If any of you enter the masjid, then do not sit down until you pray two rak’ah», [It’s authenticity is agreed upon (by both Imaam al-Bukhaaree and Imaam Muslim]
As for the prayer after the Maghrib [prayer] adhaan, and before the iqaamah, [then] it is a Sunnah based upon the saying of the Prophet (sal-Allaahu ‘alayhi wa sallam):
«Pray before the Maghrib [prayer], pray before the Maghrib [prayer]…» and thirdly he said:
«…whoever wishes [to do so]», [Transmitted by al-Bukhaaree]
And the companions of the Prophet (sal-Allaahu ‘alayhi wa sallam) would hasten to perform the two rak’ah [Sunnah] prayer before the iqaamah of [the] Maghrib [prayer] and the Prophet (sal-Allaahu ‘alayhi wa sallam) would see them [doing so] and did not prohibit them from that, rather he encouraged them in that as mentioned in the earlier hadeeth.