HONG KONG- Nearly 600,000 Hong Kong citizens cast ballots over the weekend in what the Chinese-ruled city's opposition camp said was a symbolic protest vote against a tough national security law directly imposed by Beijing.

The unofficial poll will decide the strongest pro-democracy candidates to contest elections in September to Hong Kong's Legislative Council. Then, they aim to seize majority control for the first time from pro-Beijing rivals by riding a wave of anti-China sentiment stirred by the law, which critics say has gravely undermined Hong Kong's freedoms.

While the primaries are only for the opposition camp, the level of participation is seen as a guide to popular opinion in the city of 7.5 million people, a major financial hub.

"A high turnout will send a very strong signal to the international community, that we Hong Kongers never give up," said Sunny Cheung, 24, one of a batch of aspiring young democrats out lobbying and giving stump speeches.

"And that we still stand with the democratic camp, we still support democracy and freedom."

Defying warnings from a senior Hong Kong official that the vote might fall foul of the national security law, residents young and old flocked to over 250 polling stations across the city, manned by thousands of volunteers.

Long queues formed, with people voting via their mobile phones after having their identities verified.

Organisers said 582,000 people had voted at the end of two full days of polling -- more than expected, and representing around a third of voters who backed the democrats in an election last year.

"Even under the shadow of the national security law, there were still 600,000 people coming out," said an organiser, Au Nok-hin. "You can see the courage of the Hong Kong people in this ... Hong Kongers have created another miracle."

The new law punishes what China describes broadly as secession, subversion, terrorism and collusion with foreign forces with up to life in prison and allows mainland security agents to operate officially in Hong Kong for the first time.

Despite this tactical vote to maximise their chances, some pro-democracy activists fear authorities may yet try to stop some candidates from running in September's election.

"They can arrest or disqualify any candidate they don't like under the national security law without a proper reason," said Owen Chow, a young democratic "localist" candidate.

At a time when Hong Kong authorities have barred public marches and rallies for months on end amid coronavirus social restrictions, and arrested individuals for shouting slogans and holding up blank sheets of paper, the vote was seen as a crucial and rare window for populist expression.

"I can really feel that young people haven't given up yet, even though we are facing a very depressing future," said Prince Wong, 22, a candidate in the New Territories West district.

"It helps me become more determined to fight."

(Writing by James Pomfret; Editing by Catherine Evans) ((james.pomfret@thomsonreuters.com; +852-28436390; Reuters Messaging: james.pomfret.thomsonreuters.com@reuters.net))