A Chinese professor who traces his lineage to Confucius — China’s ancient champion of harmony and courtesy — has stirred an angry bout of disharmony with a tirade against Hong Kong as a land of “dogs” and “thieves” in thrall to British colonialism.

Ignoring his illustrious ancestor’s injunction that a “gentleman should speak carefully,” Kong Qingdong of Peking University hurled abuse at the former British colony during an appearance on an Internet television talk show.

Furious at the remarks, scores of protesters gathered Sunday outside the Liaison Office of the Central People’s Government, Beijing’s main representative office in Hong Kong. Several paraded pet dogs. Others unfurled banners denouncing the Beijing academic. “We are not dogs,” the protesters shouted.

The furor dominated the front pages of Hong Kong’s major newspapers over the weekend and darkened a festive mood on the eve of Chinese New Year. Monday is the first day of the Year of the Dragon. The professor’s comments also added fuel to a growing debate over identity in Hong Kong, which returned to Chinese rule 15 years ago but whose residents feel separate from — and frequently superior to — Chinese from the mainland.

A survey of public opinion last month found that feelings of kinship with the rest of China have declined since Britain pulled out in 1997. The number of respondents who said they view themselves as Hong Kongers was more than double the number who see themselves as Chinese. China’s senior official in Hong Kong denounced the survey as “unscientific.” Communist Party-controlled media vilified a prominent Hong Kong academic who conducted the poll, alleging a foreign-backed plot to weaken Hong Kong’s ties to China.

Though ethnically and culturally Chinese, this city’s 7 million residents — who mostly speak Cantonese rather than Mandarin, China’s official language — often feel distant from their mainland cousins, who visit in growing numbers and have acquired a reputation for boorishness.

Kong, the Peking University professor, made his remarks after video footage of a quarrel between mainlanders and Hong Kongers appeared on the Internet last week. The video, which attracted widespread attention on the mainland, showed a Hong Kong passenger on the city’s subway system telling a noodle-munching mainlander in Cantonese that eating on the train is forbidden. A shouting match erupted and then continued on the platform after someone pressed the emergency button.

“Many Hong Kong people don’t think they are Chinese. They shout: ‘We are Hong Kong; you are China,’ ” Kong said, mocking the Hong Kong Cantonese accent. “These kinds of people got accustomed to being running dogs for British imperialists. Until now they are still dogs.” Such people, he added, “are not human. . . . They are dogs of imperialism.”

Leading Hong Kong politicians swiftly denounced the Beijing academic, who is well-known in China for his sharp tongue and hard-edged nationalist views.

“Hong Kong people are not dogs,” said Henry Tang, who is in the running to become Hong Kong’s next chief executive, in a contest to be decided this year by a 1,200-member committee. His main rival, Leung Chun-ying, said the professor’s insults did not represent the views of most people on the mainland.

“Down with the Barking Dog Professor,” said a banner headline in Hong Kong’s Oriental Daily News. The paper warned that “contradictions between China and Hong Kong are getting deeper by the day.” The professor at the center of the storm, it added, “didn’t just disgrace his position as a scholar but also disgraced his ancestor,” Confucius.

Kong’s outburst provoked dismay as well as applause from fellow mainlanders. “Hong Kongers are dogs, and what Mr. Kong said is right,” said a posting on Weibo, a Chinese version of Twitter. Official media either ignored or played down the controversy.

Meanwhile, the professor retreated slightly. He denied describing all Hong Kongers as “dogs” and said his words had been “twisted by media.”

Jackson Szeto, a Hong Kong resident who joined Sunday’s protest, scoffed at the denial. “We all know what he said. . . . He is the dog, not us.”

Another protester, retired engineer Roger Chow, said Hong Kongers feel Chinese but don’t like the Communist Party, which he said had deformed Chinese culture and tradition. “I’m not against fellow Chinese from the mainland,” he said, “but the party is not China.”