Thank you for your question. Loving one's country and its people is a good trait of Muslims, as our beloved Prophet Muhammad (peace and blessings be upon him) has amply demonstrated. This is what we mean by patriotism.
But there is an intense form of it called nationalism that urges people to adopt the position that their country is right and should be supported in whatever it does, even if that means supporting injustice.
Muslims have to necessarily abide by Allah's commandments regarding truth and justice. Therefore, they cannot adopt an attitude of blind patriotism or nationalism because it tends to instill into people a belief that their nation is superior to other nations, notwithstanding the principle of human equality and brotherhood upheld by Islam.
Besides, extreme nationalists relegate God and His religion to a secondary status, placing nationalist considerations uppermost. And nationalism tends to pit one nation against another in pursuit of political hegemony or economic exploitation. They reject the guidance of God to adopt short-sighted jingoism out of a desire to dominate other nations.
Nationalists do not stand for justice in causes, but cling to narrow sectarian allegiance. Hence they may oppose Muslims who support those fighting for their basic human rights irrespective of national borders, such as the Palestinians, the Iraqis, or the Chechens.
Nationalists' political philosophy is derived from ancient tribal affinities and goes back to pre-Islamic times. As observed by the Muslim scholar Dr. Yusuf Al-Qaradawi, the ideology of nationalism was first planted in Muslim societies by Western occupiers and their stooges.
Muslims living in the contemporary world should be realistic enough to adopt a policy of harmony and peace as far as possible. They should understand that the national flag and national anthem are powerful symbols of a country, and respecting them simply means that they are ready to live there as loyal citizens.
Disrespecting the national flag or the anthem would be considered an open challenge to the government attracting due punishment.
Moreover, Islam orders us to do our best to become good citizens in the countries we live in. Muslims have to honor the laws of the country where they live as long as such laws do not contradict the teachings of Islam.
In this connection the opinion of Sheikh Faysal Mawlawi, deputy chairman of the European Council for Fatwa and Research, is relevant:
Muslims living in non-Muslim countries are to respect the symbols of those countries such as the national anthem, national flag, etc. This is part of what citizenship dictates as per modern customs. … Thus, standing up for the national anthem is not a form of prohibited loyalty. If a Muslim is to change a wrong action in a majority non-Muslim country, let him do that through da`wah, wisdom, and fair exhortation. At the same time, he should not obey any rules that involve disobedience to Allah.
When Muslims living in non-Muslim countries stand up to respect their national anthems, their intention is not to approve the un-Islamic rulings prevalent in those countries. They are simply performing a national duty, that is, loving their nation.
And this expression of patriotism has nothing to do with worship, as there is neither prayer nor remembrance of God involved in it. Thus, it cannot be called a prohibited act.