Short answer
Scholars differ. The 4th of July is a national holiday, not a religious festival, so many scholars allow enjoying the day off, a halal barbecue and gratitude for your country's freedoms, as long as it is not treated like an Eid. Many Hanafi muftis advise against taking part in the celebrations themselves, since Islam has two festivals, and warn against waste and haram elements.
Muslims have two festivals, Eid al-Fitr and Eid al-Adha. Treating a national day as a festival is discouraged by many Hanafi muftis. Spending the public holiday with family, without its haram parts and without treating it as an Eid, is not sinful.
The four schools agree on this.
Explanation
When the Prophet ﷺ came to Madinah, the people had two days on which they played and celebrated. He told them that Allah had replaced those days with two better ones: the day of Adha and the day of Fitr. Scholars take from this that Muslims should not set up other annual festivals alongside the two Eids.
The 4th of July is different from Christmas or Diwali: it marks a political event, independence, and has no act of worship at its centre. That is why scholars differ:
- The cautious view, held by many Hanafi muftis: making any day an annual celebration with fireworks, parades and parties copies a festival culture Islam replaced, and the day is full of music, alcohol and waste.
- The lenient view, held by a number of scholars in America: it is a civic holiday like Labor Day. Loving the land you live in, being grateful for safety and freedom to practise Islam, and enjoying a day off with family are permitted, as long as it is never treated as an Eid.
Points both views share:
- Meat at the barbecue must be halal.
- Avoid alcohol, music, mixed parties and immodest dress.
- Large spending on fireworks is waste. Allah says the wasteful are brothers of the devils. Watching a public display is lighter than buying your own.
- A Muslim can be a loyal, grateful citizen and still keep his festivals for Allah.
The same reasoning applies to Independence Day elsewhere, Canada Day, Australia Day and similar national days. Religious festivals of other faiths are a separate question, covered in the interfaith section. See also Thanksgiving and Eid dates.
The evidence
Quran, Surah Al-Israa 17:27
إِنَّ ٱلْمُبَذِّرِينَ كَانُوٓا۟ إِخْوَٰنَ ٱلشَّيَٰطِينِ ۖ وَكَانَ ٱلشَّيْطَٰنُ لِرَبِّهِۦ كَفُورًۭا ﴿٢٧﴾
Indeed, the wasteful are brothers of the devils, and ever has Satan been to his Lord ungrateful.
Spending heavily on fireworks and parties can be waste.
Sunan Abi Dawud 1134
Graded sahih... إن الله قد أبدلكم بهما خيرا منهما يوم الأضحى ويوم الفطر ...
"Allah has replaced them for you with two better days: the day of Adha and the day of Fitr."
Muslims have two annual festivals.
Where the ruling is recorded
- Radd al-Muhtar (Ibn Abidin), Kitab al-Salah, chapter on what invalidates the prayer and what is disliked in it. Resembling others is blameworthy only in what is bad in itself or when resemblance is intended.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.