China has made disrespect of the national anthem a crime punishable by up to three years in jail, as it focuses on cementing the patriotic “China dream” of its increasingly authoritarian president, Xi Jinping.

The new law is likely to alarm citizens of Hong Kong and Macau, where the March of the Volunteers has been a flashpoint for unrest, amid growing concerns about Beijing’s efforts to exert its control over the city states.

Some Hong Kong football fans have booed the anthem during World Cup qualifiers and other matches.

Pro-democracy activists fear the law will be used to undermine freedom of speech and protest, after a punishing year of setbacks including the jailing of prominent members of the democracy movement for their roles in anti-government protests.

Citizens of Hong Kong and Macau are not directly subject to the law, passed on Saturday by China’s rubber-stamp parliament, because they have their own legal systems. But a separate decree mandating 15 days in jail for disrespect of the flag was also written into their constitutions, or Basic Law.

Senior lawmakers said that the new rule would be taken seriously, with people expected to get to their feet at social events, and anyone walking along the street required to stand still.

“Sometimes when the anthem is played at the Jockey Club, many people do not stand up,” Li Fei, chair of the Basic Law committee, was quoted as saying by the South China Morning Post. “This must change after the legislation comes into effect.”

The new law is aimed at anyone found to be “seriously” disrespecting the national anthem including by reworking its lyrics, although there are few if any reports of the anthem being used for protests within China itself. The national flag and emblem were already protected by a similar law.

The move comes after Xi last month cemented his position as the country’s most powerful leader since Mao Zedong, and was appointed to a second five-year term as party leader.

He has put the “China dream” for a more prosperous and powerful nation at the heart of his political vision, promising to extend prosperity and restore international prestige. But at home he has enforced a narrow vision of progress, cultivating a personality cult and cracking down on dissent.