HONG KONG — A committee dominated by supporters of the Chinese government chose Carrie Lam as Hong Kong’s next leader on Sunday, opting for Beijing’s preferred candidate in a move likely to dismay residents who see the city’s freedoms as being under threat from China.

Mrs. Lam, a former No. 2 official in the city, received 777 out of 1,163 votes cast to become the next chief executive, as Hong Kong’s leader is called. She defeated John Tsang, a former finance secretary who polls indicated was more popular with the public.

The leader of this semiautonomous Chinese city of 7.3 million is chosen by just 1,194 electors, most of them business and political figures who have close ties to Beijing.

In an apparent act of protest, one elector drew a cross on the ballot with check marks, and another wrote an obscenity on it.