A Muslim may not celebrate or participate in a non-Muslim festival. Celebration or participation may indicate an endorsement of such an occasion and its principle. Celebrations are characteristic of groups and, as Muslims, we have our own celebrations and festivals. Also, imitating a group may render one to be a member of such a group. Hence, as Muslims, we should treat Valentine's Day as any other day and do nothing special whatsoever (dining included) on this day.
Origin of Saint Valentine's Day
Valentine's Day is a Christian festival celebrated on February 14th (mostly, but some churches celebrate it on other days in July) of every year to commemorate one of their third-century saints (Saint Valentine).
In addition to its Christian origin, a commercial celebration of romance and love also takes place (presumably started in the 14th century with the tradition of courtly love), and over time, this was manifested by presenting flowers and confectionery (typically by men to women, although in some parts of the world, it is the other way round).
Alban Butler and Francis Douce have debated that Saint Valentine's Day was actually the Roman pagan holiday of Lupercalia, but Professor Jack B. Oruch (University of Kansas) argued that this was incorrect and that current legends of this day started in the 14th century in England by Geoffrey Chaucer.
While the origin of Saint Valentine's Day remains to be a matter of debate, no claim is known that it has an Islamic origin; it is either a Roman pagan holiday, a Christian martyrdom day, or a romance-based English celebration.
Evidence from the Qur'an and Sunnah
Allah ﷻ tells us in the Qur'an that every religion has its own assigned rituals, and that different groups may have different rituals:
لِّكُلِّ أُمَّةٍ جَعَلْنَا مَنسَكًا هُمْ نَاسِكُوه
فَلَا يُنَازِعُنَّكَ فِي الْأَمْرِ وَادْعُ إِلَىٰ رَبِّكَ ۖ إِنَّكَ لَعَلَىٰ هُدًى مُّسْتَقِيمٍ
For every religion We have appointed rites which they perform. So, [O Muhammad], let the disbelievers not contend with you over the matter but invite them to your Lord. Indeed, you are upon straight guidance.
— Surat Al-Haj 22:67
At-Tabari said that an appointed rite (mansak, Arabic: منسك) refers a tradition (which was the opinion of 'Abdullah ibn 'Abbās), or a place that one frequents under specific conditions (good or evil), or a celebration or a festival (which was the opinion of Qatada and Mujahid), or a time when a sacrifice is offered.
This concept was manifested on another occasion when some young girls were celebrating Eid in the house of 'Ā'isha:
حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا أَبُو أُسَامَةَ، عَنْ هِشَامٍ، عَنْ أَبِيهِ، عَنْ عَائِشَةَ، قَالَتْ دَخَلَ عَلَىَّ أَبُو بَكْرٍ وَعِنْدِي جَارِيَتَانِ مِنْ جَوَارِي الأَنْصَارِ تُغَنِّيَانِ بِمَا تَقَاوَلَتْ بِهِ الأَنْصَارُ يَوْمَ بُعَاثٍ قَالَتْ وَلَيْسَتَا بِمُغَنِّيَتَيْنِ. فَقَالَ أَبُو بَكْرٍ أَبِمُزْمُورِ الشَّيْطَانِ فِي بَيْتِ رَسُولِ اللَّهِ صلى الله عليه وسلم وَذَلِكَ فِي يَوْمِ عِيدٍ. فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم: يَا أَبَا بَكْرٍ
إِنَّ لِكُلِّ قَوْمٍ عِيدًا وَهَذَا عِيدُنَا
'A'isha reported: Abu Bakr came to see me and I had two girls with me from among the girls of the Ansar and they were singing what the Ansar recited to one another at the Battle of Bu'ath. They were not, however, singing girls. Upon this Abu Bakr said: What I (the playing of) this wind instrument of Satan in the house of the Messenger of Allah (ﷺ) and this too on 'Id day? Upon this, the Messenger of Allah (ﷺ) said: Abu Bakr, every people have a festival and it is our festival (so let them play on).
— Sahih Muslim, Book 8, Hadith 16
This hadith shows that every group of people has its own celebrations and festivals. The Arabic form used (إن لكل قوم عيداً وهذا عيدنا) shows exclusivity. In the first part of the sentence, the Prophet ﷺ declares the exclusivity of festivals (إن لكل قوم عيداً), which resonates with Qur'an 5:48 (To each of you We prescribed a law and a method, Arabic: لِكُلٍّ جَعَلْنَا مِنكُمْ شِرْعَةً وَمِنْهَاجًا), and the second part (وهذا عيدنا) declared that day as a Muslim festival. This shows that permissibility of celebration is limited only to Muslim festivals.
The Prophet ﷺ showed us on another occasion that we as Muslims should not celebrate the festivals of others as we have been given the best of festivals, namely 'Eid al-Fitr and 'Eid al-Adha:
حَدَّثَنَا مُوسَى بْنُ إِسْمَاعِيلَ، حَدَّثَنَا حَمَّادٌ، عَنْ حُمَيْدٍ، عَنْ أَنَسٍ، قَالَ قَدِمَ رَسُولُ اللَّهِ صلى الله عليه وسلم الْمَدِينَةَ وَلَهُمْ يَوْمَانِ يَلْعَبُونَ فِيهِمَا فَقَالَ: مَا هَذَانِ الْيَوْمَانِ. قَالُوا كُنَّا نَلْعَبُ فِيهِمَا فِي الْجَاهِلِيَّةِ. فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم: إِنَّ اللَّهَ قَدْ أَبْدَلَكُمْ بِهِمَا خَيْرًا مِنْهُمَا يَوْمَ الأَضْحَى وَيَوْمَ الْفِطْرِ
Narrated Anas ibn Malik: When the Messenger of Allah (ﷺ) came to Medina, the people had two days on which they engaged in games. He asked: What are these two days (what is the significance)? They said: We used to engage ourselves with them in the pre-Islamic period. The Messenger of Allah (ﷺ) said: Allah has substituted for them something better than them, the day of sacrifice and the day of the breaking of the fast.
— Sunan Abi Dawud, Book 2, Hadith 745
The hadith above shows that the Prophet ﷺ did not endorse the celebration of pre-Islamic festivals and that our annual festivals as Muslims are two festivals. Even the weekly day of celebration for Muslims is Friday, which differs from the Jews (Saturday) and Christians (Sunday) as per the hadith below:
حَدَّثَنَا عَمْرٌو النَّاقِدُ، حَدَّثَنَا سُفْيَانُ بْنُ عُيَيْنَةَ، عَنْ أَبِي الزِّنَادِ، عَنِ الأَعْرَجِ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم: نَحْنُ الآخِرُونَ وَنَحْنُ السَّابِقُونَ يَوْمَ الْقِيَامَةِ بَيْدَ أَنَّ كُلَّ أُمَّةٍ أُوتِيَتِ الْكِتَابَ مِنْ قَبْلِنَا وَأُوتِينَاهُ مِنْ بَعْدِهِمْ ثُمَّ هَذَا الْيَوْمُ الَّذِي كَتَبَهُ اللَّهُ عَلَيْنَا هَدَانَا اللَّهُ لَهُ فَالنَّاسُ لَنَا فِيهِ تَبَعٌ الْيَهُودُ غَدًا وَالنَّصَارَى بَعْدَ غَدٍ
Abu Huraira reported Allah's Messenger (ﷺ) as saying: We who are the last shall be the first on the Day of Resurrection, except that every Ummah was given the Book before us and we were given it after them. It was this day which Allah prescribed for us and guided us to it and the people came after us with regard to it, the Jews observing the next day and the Christians the day following that.
— Sahih Muslim, Book 7, Hadith 28
The evidence to this effect is abundant. On another occasion, a man vowed to offer a camel as a sacrifice at a specific place called Buwānah. The first thing the Prophet ﷺ asked about was if that place had any idols (as it may seem to some as if the sacrifice was being offered to such idols). When told there were no idols there, his second question was about it being a pre-Islamic festival:
حَدَّثَنَا دَاوُدُ بْنُ رُشَيْدٍ، حَدَّثَنَا شُعَيْبُ بْنُ إِسْحَاقَ، عَنِ الأَوْزَاعِيِّ، عَنْ يَحْيَى بْنِ أَبِي كَثِيرٍ، قَالَ حَدَّثَنِي أَبُو قِلاَبَةَ، قَالَ حَدَّثَنِي ثَابِتُ بْنُ الضَّحَّاكِ، قَالَ: نَذَرَ رَجُلٌ عَلَى عَهْدِ رَسُولِ اللَّهِ صلى الله عليه وسلم أَنْ يَنْحَرَ إِبِلاً بِبُوَانَةَ، فَأَتَى النَّبِيَّ صلى الله عليه وسلم فَقَالَ: إِنِّي نَذَرْتُ أَنْ أَنْحَرَ إِبِلاً بِبُوَانَةَ. فَقَالَ النَّبِيُّ صلى الله عليه وسلم: هَلْ كَانَ فِيهَا وَثَنٌ مِنْ أَوْثَانِ الْجَاهِلِيَّةِ يُعْبَدُ. قَالُوا: لاَ. قَالَ: هَلْ كَانَ فِيهَا عِيدٌ مِنْ أَعْيَادِهِمْ. قَالُوا: لاَ. قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم: أَوْفِ بِنَذْرِكَ، فَإِنَّهُ لاَ وَفَاءَ لِنَذْرٍ فِي مَعْصِيَةِ اللَّهِ وَلاَ فِيمَا لاَ يَمْلِكُ ابْنُ آدَمَ
Narrated Thabit ibn ad-Dahhak: In the time of the Prophet (ﷺ) a man took a vow to slaughter a camel at Buwanah. So he came to the Prophet (ﷺ) and said: I have taken a vow to sacrifice a camel at Buwanah. The Prophet (ﷺ) asked: Did the place contain any idol worshipped in pre-Islamic times? They (the people) said: No. He asked: Was any pre-Islamic festival observed there? They replied: No. The Prophet (ﷺ) said: Fulfil your vow, for a vow to do an act of disobedience to Allah must not be fulfilled, neither must one do something over which a human being has no control.
— Sunan Abi Dawud, Book 22, Hadith 72
This hadith shows that observing a place or a time that non-Muslims observe for a sacrifice is forbidden unless there is a dedicated verse in the Qur'an or a hadith that instructs us to do otherwise. It is also known from the seerah of the Prophet ﷺ and the companions afterward that none observed any of the festivals of the Jews, Christians, Persians, Romans, etc., without a direct order (only 'Āshūrā' to be specific). It is well documented that all said groups existed at the same time and that the Prophet ﷺ and his companions interacted with them and were aware of their celebrations and festivals.
After the Prophet ﷺ died, during the time of 'Umar ibn al-Khattab, one of his conditions to ahl adh-dhimma (non-Muslims who elected to pay jizyah and stay in dār al-Islam, i.e., countries ruled by Muslims) that they do not openly celebrate their festivals (they were allowed to celebrate their festivals in their homes or places of worship). 'Umar wrote to his rulers in all the Muslim countries as documented in this authentic athar in Musnad al-Fārūq by Ibn Kathir (an authentic athar), among many other books:
لا تعلموا رطانة الأعاجم ولا تدخلوا على المشركين في كنائسهم يوم عيدهم فإن السخطة تنزل عليهم
— NOTE: My own translation, so treat with care:
Do not teach the pidgin of non-Arabs, and do not enter onto non-believers in their churches during their festivals for [Allah's] anger is upon them.
— Musnad al-Fārūq, Vol. 344, pp. 344
In another athar attributed to 'Umar that was documented by Al-Bayhaqi in his book As-Sunan al-Kubra, he made it very clear not only not to celebrate but to avoid altogether the celebrations of non-Muslims:
اجتنبوا أعداء الله في عيدهم
— NOTE: My own translation, so treat with care:
Stay away from the enemies of Allah on their festival.
— As-Sunan al-Kubra 9/392/18862
It is important to understand that as Muslims, we have our own law and method, and non-Muslims have their own laws and methods and that Allah could have made us all one nation, had He willed, but He did not:
وَأَنزَلْنَا إِلَيْكَ الْكِتَابَ بِالْحَقِّ مُصَدِّقًا لِّمَا بَيْنَ يَدَيْهِ مِنَ الْكِتَابِ وَمُهَيْمِنًا عَلَيْهِ ۖ فَاحْكُم بَيْنَهُم بِمَا أَنزَلَ اللَّهُ ۖ وَلَا تَتَّبِعْ أَهْوَاءَهُمْ عَمَّا جَاءَكَ مِنَ الْحَقِّ
لِكُلٍّ جَعَلْنَا مِنكُمْ شِرْعَةً وَمِنْهَاجًا
وَلَوْ شَاءَ اللَّهُ لَجَعَلَكُمْ أُمَّةً وَاحِدَةً وَلَٰكِن لِّيَبْلُوَكُمْ فِي مَا آتَاكُمْ ۖ فَاسْتَبِقُوا الْخَيْرَاتِ ۚ إِلَى اللَّهِ مَرْجِعُكُمْ جَمِيعًا فَيُنَبِّئُكُم بِمَا كُنتُمْ فِيهِ تَخْتَلِفُونَ
And We have revealed to you, [O Muhammad], the Book in truth, confirming that which preceded it of the Scripture and as a criterion over it. So judge between them by what Allah has revealed and do not follow their inclinations away from what has come to you of the truth. To each of you We prescribed a law and a method. Had Allah willed, He would have made you one nation [united in religion], but [He intended] to test you in what He has given you; so race to [all that is] good. To Allah is your return all together, and He will [then] inform you concerning that over which you used to differ.
— Surat Al-Ma'idah 5:48
It is, therefore, crucial to stick exclusively to our own celebrations, and avoid altogether their celebrations in any form, even if just witnessing without participation:
وَالَّذِينَ لَا يَشْهَدُونَ الزُّورَ وَإِذَا مَرُّوا بِاللَّغْوِ مَرُّوا كِرَامًا
And those who do not witness falsehood, and if they pass by some evil play or evil talk, they pass by it with dignity.
— Surat Al-Furqan [25:72]
Ibn Sirin, when asked about "witnessing falsehood" in this verse, he said that it pertained to Palm Sunday. Ar-Rabī' ibn Anas said that it pertained to all celebrations and festivals of non-believers. So witnessing non-Muslim festivals would be considered participating in falsehood at best, and may even be considered a path to kufr if one's intention is to copy them, as one would become one of them:
حَدَّثَنَا عُثْمَانُ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا أَبُو النَّضْرِ، حَدَّثَنَا عَبْدُ الرَّحْمَنِ بْنُ ثَابِتٍ، حَدَّثَنَا حَسَّانُ بْنُ عَطِيَّةَ، عَنْ أَبِي مُنِيبٍ الْجُرَشِيِّ، عَنِ ابْنِ عُمَرَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم: مَنْ تَشَبَّهَ بِقَوْمٍ فَهُوَ مِنْهُم
Narrated Abdullah ibn Umar: The Prophet (ﷺ) said: He who copies any people is one of them.
— Sunan Abi Dawud, Book 34, Hadith 12
It is important to note that the above is not by any means a comprehensive list of all the evidence from the Qur'an and Sunnah; it is merely, a collection of some of the verses, ahādith, and athār related to the topic of the question.
Opinions of scholars of jurisprudence
Based on the above evidence, it is no surprise that there is no known difference of opinions among scholars that can be taken into consideration. Below are some of the views of prominent scholars on the topic of celebrating non-Muslim festivals in general, and celebrating Saint Valentine's Day in particular.
In Iqtidā' as-Sirat al-Mustāqīm (Arabic: اقتضاء الصراط المستقيم لمخالفة أصحاب الجحيم) by Ibn Taymiyyah, Vol. 1, pp. 528-530, he said that a Muslim is not permitted to celebrate or participate in the festivals of non-Muslims and that celebrations and festivals are restricted to what has been explicitly declared through a verse [Qur'an or hadith]. He elaborated that for every nation, there is a prescribed law and method (5:48) and that those who follow such a law or method belong to said group (22:67) with festivals and celebrations being an exclusive characteristic of each group. Celebrating with them is an endorsement of their creed (which is kufr), and participating is partial kufr. At best, such an act would be a sin.
Ibn Taymiyyah in Majmū' al-Fatāwa (Arabic: مجموع الفتاوى), Vol. 26, pp. 329, said that Muslims are not allowed to copy non-Muslims when it comes to celebrations, neither in food nor in clothes nor in washing nor in lighting fire nor in stopping a frequented act (through habit or through religious rituals) nor in banqueting nor in gifting nor in trading nor in anything that aids in any of the preceding acts nor for its sake. He elaborated that letting children play at such events is also not permitted and that Muslims should not have any form of public display of participation in such events.
Ibn Qayyim al-Jawziyya in Ahkām Ahl adh-Dhimma (Arabic: أحكام أهل الذمة), Vol. 1, pp. 441, said that congratulating non-Muslims on one of their festivals, which equates to congratulating them on their disbelief, is agreed upon to be harām (not permitted and punishable). He elaborated that this may lead to kufr at worst, or being a sin at best, as it would be congratulating a person for committing an act of shirk, drinking wine, killing a soul, etc.
Adh-Dhahabi said in Tashabboh al-Khassīss bi Ahl al-Khamīs (Arabic: تشبه الخسيس بأهل الخميس) that if Christians or Jews had a festival that was particular to them, no Muslim should participate in their celebration as no Muslim participates in their religious method or qibla. He then added that it was well known that 'Umar ibn al-Khattab ordered them [Jews and Christians] not to openly celebrate their festivals.
As celebrating Saint Valentine's Day by Muslims is relatively new in the Muslim world, there are several recent fatwas that are specific to this day. In Fatāwa wa Istisharāt al-Islam al-Yawm (Arabic: فتاوى واستشارات الإسلام اليوم), Vol. 4, pp. 37, Ibn al-'Uthaymeen was asked about celebrating Saint Valentine's Day. He responded saying that celebrating Saint Valentine's Day is not allowed as it is not a Muslim festival, that it commemorates love outside wedlock, and that it occupies the heart with trivial matters that were not practiced by the salaf [companions, their followers, and the followers of their followers]. He added that it is harām to celebrate the day in any form, let that be dining, drinking, clothing (specific colors or otherwise), gifting, etc.
The Permanent Committee had a similar fatwa (see Fatāwa al-Lagna ad-Dā'ima Vol. 3, pp. 263) and so did Abdullah Ibn Jibreen (see Fatāwa wa Istisharāt al-Islam al-Yawm, Vol. 4, pp. 35). Their opinions concur with all the above fatwas.
Again, this is not meant to be a conclusive list of all fatwas on the topic; rather, the tip of the iceberg when it comes to this topic of celebrating or participating in non-Muslim festivals.