Hong Kong civil servants swore a new pledge of allegiance to the government Wednesday in the first ceremony overseen by the city's leader to enforce greater loyalty in the governing class after last year's huge democracy protests.

Chief executive Carrie Lam stood before a group of senior officials at a closed-door ceremony for the pledge, which all the finance hub's 180,000 civil servants will be expected to make in the coming weeks.

Those taking the oath promise to uphold Hong Kong's mini-constitution and "bear allegiance" to the city and its government.

A government spokesperson said the oath-taking would "strengthen the public's confidence in political-appointed officials".

Civil servants were one of the groups that took to the streets in large numbers last year calling for greater democracy and police accountability.

Tens of thousands joined one rally that was expressly organised by civil servants -- some of whom posted anonymised ID cards online as a way to signal their support for the movement -- a move that infuriated Beijing.

All of Hong Kong's 180,000 civil servants will be expected to make the loyalty oath in the coming weeks
All of Hong Kong's 180,000 civil servants will be expected to make the loyalty oath in the coming weeks INFORMATION SERVICES DEPARTMENT / Handout

China's authoritarian leaders dismissed the protests and have overseen a widespread crackdown on dissent in the city this year.

It imposed a sweeping security law on the territory in June and has called for patriotism and loyalty to be installed across Hong Kong society.

The pledges are part of that drive.

The city's civil service minister has warned those who refused to take an oath of loyalty or sign similar declarations could lose their jobs.

Authorities argue civil servants have to abide by political neutrality rules and should not have joined last year's protests.

Local media reported other ranks of civil servants will be asked to sign declarations of loyalty and the whole process is expected to be completed next month.

All new hires within the civil service already have to sign a mandatory loyalty pledge.