By Venus Wu and James Pomfret

HONG KONG (Reuters) - Several pro-independence candidates won seats in Hong Kong's first major election since pro-democracy protests in 2014, prompting a robust warning from China that any independence would damage the city's security and prosperity.

In comments carried by the official Xinhua news agency, China's Hong Kong and Macao Affairs Office said it "resolutely opposed" any form of independence for Hong Kong, noting this would violate China's constitution.

The election of a new generation of pro-democracy activists in a record turnout in Chinese-controlled Hong Kong on Sunday underscores a deep divide in a city of more than 7 million people where tensions with Beijing are intensifying.

China bristles at open dissent, especially over sensitive matters such as demands for universal suffrage, and many in Hong Kong are increasingly concerned about what they see as Beijing's meddling in the city's affairs.

In the election, the pro-democracy opposition also kept its crucial one-third veto bloc in the 70-seat Legislative Council over major laws and public funding that has helped check China's influence.

The vote, which ushered in a new crop of legislators including a 23-year-old former protest leader who vowed to "fight" the Chinese Communist Party, underscores growing frustration with how Beijing has handled its "special administrative region" and marks a significant turning point.

The former British colony was handed back to China in 1997 under a "one country, two systems" agreement that promised to maintain the global financial hub's freedoms and separate laws for at least 50 years, but gave ultimate control to Beijing.

Beijing officials have repeatedly warned Hong Kong not to stray too far.

Despite the disqualification of six pro-democracy election candidates from the election in July on the grounds that they backed independence, at least five "localists" and younger democratic newcomers won seats, including Nathan Law, one of the leaders of mass democracy protests in 2014.

Those protests posed one of the greatest challenges to Beijing's rule in decades and were deemed illegal by the local government in Hong Kong and the central government in Beijing.

Localists put the interests of Hong Kong before those of Beijing.

"I'm quite shocked," said Law. "We inherit some spirit from the movement and I hope that can continue in the future... We still have to unite in order to have stronger power to fight the Chinese Communist Party."

"PEOPLE WANT CHANGE"

Sunday's vote was the first major election since the 2014 student-led "Umbrella Revolution" protests that blocked roads for 79 days.

Since then, many disaffected youngsters have decried what they see as increasing Beijing interference stifling dissent and civil liberties, leading to a radicalisation of the political scene and occasional violent protests.

Several veteran democrats lost their seats, as voters backed a new batch of younger candidates espousing self-determination and a more confrontational stance with China.

"It's a new era," said Lee Cheuk-yan, a democratic lawmaker who lost his seat after more than two decades in public office.

"People want change, change meaning that they want new faces ... but the price is a further fragmentation (of the democracy camp). Ideologically they're talking about independence and they want to assert themselves."

Hong Kong Secretary for Constitutional Affairs Raymond Tam said the government would do its best to "bring them around to a more centrist position".

"But it's too early to say if this will be an issue," he said.

Pro-establishment lawmakers like Elizabeth Quat said she hoped the issue of splitting from China wouldn't enter the legislature or it could damage Hong Kong's economic interests.

"Independence is not realistic at all," she said. "Hopefully this will not be their main objective."

Voters flocked to cast ballots in record numbers with some having to wait several hours after polls closed, leading to some delays in vote counting on Monday.

"Hong Kong is really chaotic now. I want to do something to help," said 28-year-old Maicy Leung, who was in a snaking queue of several hundred. "It's to help the next generation and to help myself."

The Electoral Affairs Commission said 58 percent of an eligible 3.8 million voters had cast their ballot, up from 53 percent in 2012 and the highest legislative election turnout since 1997.

(Additional reporting by Sharon Shi, Stefanie McIntyre, Donny Kwok and Clare Baldwin in Hong Kong and the Beijing newsroom; Editing by Nick Macfie and Ian Geoghegan)