Thousands of pro-Beijing demonstrators have rallied in Hong Kong in support of China's decision to effectively bar two pro-independence legislators from taking office.

On Sunday, large crowds of people gathered outside Hong Kong's Legislative Council in a show of support for Beijing's recent decision. Police said more than 28,000 people attended the mass demonstration.

The demonstrators waved Chinese flags and expressed opposition to any attempt to separate Hong Kong from the motherland. They also chanted slogans such as "Fight against Hong Kong independence."

"The cancer cells are those who are promoting Hong Kong independence... we will fight them to the end," lawmaker Michael Tien told the crowd at the rally, adding, "China will never, ever tolerate the splitting of the nation."

Priscilla Leung, another legislator who attended the demonstration, said the lawmakers' behavior at last month's swearing-in ceremony "humiliated all of the Chinese people."

During the swearing-in ceremony last month, young lawmakers Yau Wai-ching and Sixtus "Baggio" Leung challenged China’s claim of sovereignty over Hong Kong by pledging allegiance to what they described as the Hong Kong nation.

In a ruling on November 7, the National People's Congress in Beijing adopted an interpretation of an article in Hong Kong's mini-constitution on oath-taking, saying that the pair’s oaths were "invalid," and that they must swear allegiance to Hong Kong as a Chinese city.

In an earlier pronouncement, the Chinese legislature said that those wishing to hold public office must “sincerely and solemnly” declare allegiance to China. It said talk of independence for Hong Kong was intended to “divide the country” and severely harmed the country’s unity, territorial sovereignty and national security.

Following the ruling, Hong Kong’s Chief Executive Leung Chun-ying said he would “fully implement” the ruling by the Chinese parliament, which effectively bars the two newly-elected pro-independence lawmakers from the city’s local legislature after they deliberately misread their oaths of office.

Newly-elected lawmaker Sixtus "Baggio" Leung, center, stands in front of the press in Hong Kong on November 7, 2016. (Photo by AFP)

The two lawmakers are members of the so-called Umbrella Movement that emerged after the 2014 Occupy protests failed to secure greater autonomy from the Chinese government.

The protests erupted after the Chinese government introduced an election law, under which the people of Hong Kong would have to elect their next leader from a list of candidates vetted by Beijing in 2017.

Hong Kong, a former British colony and a major global financial hub in Eastern Asia, was handed over to China in 1997 under the so-called formula of one country, two systems.