Her resignation was followed by that of one her top investigators, and the commission was forced to cancel its annual dinner after most employees decided to boycott.

Image Simon Peh oversees the anticorruption agency. He demoted the head of the department overseeing an inquiry into the city’s top official, and she later resigned. Credit... Alex Hofford/European Pressphoto Agency

The commission, set up in 1974 to combat rampant corruption in what was then a British colony, became a model of independent law enforcement and helped earn Hong Kong a reputation for clean, efficient government. After Hong Kong’s return to Chinese sovereignty in 1997, it continued to operate under an arrangement known as one country, two systems, in which China promised the city a high degree of self-rule until 2047.

But people here are increasingly concerned that Chinese influence, especially under the uncompromising rule of President Xi Jinping, is already chipping away at the city’s institutions, including the universities, the press and the police.

Those concerns set off protests this year after several book publishers based in Hong Kong vanished, only to reappear weeks later in Chinese custody. In 2014, when China’s legislature set election rules all but ensuring that only pro-Beijing candidates could run for Hong Kong’s chief executive, tens of thousands of protesters paralyzed the city center for months.

Although the anticorruption commission has proved independent enough to take down tycoons and top civil servants, Ms. Li’s departure highlights how potentially vulnerable it may be to outside political influence, including from the mainland.

The link to both, critics say, is Mr. Leung, a Beijing loyalist who has extraordinary power over the commission, enough to bend it to the mainland’s will or shield himself from scrutiny should he be so inclined.

Mr. Leung nominates the leader of the commission, as he did with Mr. Peh, who is then appointed by China’s central government.