China's top legislature on Friday passed a national anthem law to ensure appropriate use of the song.
It was adopted after a second reading at the bimonthly session of the Standing Committee of the National People's Congress, which started Monday.
The national anthem "March of the Volunteers," has lyrics by poet Tian Han and music by Nie Er.
The song will only be allowed at formal political gatherings, including the opening and closing of NPC sessions, constitutional oath ceremonies, flag raising ceremonies, major celebrations, award ceremonies, commemorations, national memorial day events, important diplomatic occasions, major sport events and other suitable occasions.
It will be illegal to use the national anthem during funerals, "inappropriate" private occasions, commercials or as background music in public places.
The law says that violators, including those who maliciously modify the lyrics or play/sing the national anthem in a distorted or disrespectful way, can be detained for up to 15 days or held criminally liable.
The song must be included in textbooks for primary and secondary school students, and people are encouraged to sing the national anthem on appropriate occasions to express patriotism.
China has already adopted laws covering its national flag in 1990 and national emblem in 1991.
"The national anthem is different from other songs, it is the symbol of our country," said well-known music composer Jin Fuzai. "The law ensures people will be more serious when playing or singing the song."
The law will enter effect on Oct. 1, 2017.