Media playback is unsupported on your device Media caption Carrie Gracie: Protesters light up the streets in the main financial district

China's Foreign Minister Wang Yi has warned against "illegal" protests in Hong Kong, amid major pro-democracy rallies in the territory.

Mr Wang, in Washington, said the matter was an "internal affair" for China.

US counterpart John Kerry urged Hong Kong to handle the protests - seen as a challenge to Beijing - with restraint.

In Hong Kong, students angry at China's plan to vet candidates for 2017 polls have vowed to step up protests if Chief Executive CY Leung does not resign.

They say they will start occupying government buildings if he does not quit by Thursday night.

Overnight, some 3,000 protesters massed outside his office, AFP news agency reports. There is a heavy police presence outside government offices, the South China Morning Post reports.

But the BBC's Juliana Liu in Hong Kong says crowds on Connaught Road in the Central district on Thursday morning were at their lowest ebb since the protest began.

Organisers have attributed this to sheer exhaustion, as the demonstration stretches into its fifth day, she says.

Media playback is unsupported on your device Media caption The US and China expressed different views about events in Hong Kong

'High hopes'

The protesters include students, supporters of pro-democracy group Occupy Central and others angered by the initial police response to rallies at the weekend, which included using tear gas.

Mr Wang, the most senior Chinese official to speak openly on the matter, said: "Hong Kong affairs are China's internal affairs. All countries should respect China's sovereignty. For any country, for any society, no-one will allow those illegal acts that violate public order."

Image copyright AFP Image caption Protesters have been sleeping on roads around government buildings for several days

Image copyright Reuters Image caption There is a heavy police presence outside the office of Chief Executive CY Leung

But he said he believed Hong Kong authorities had "the capability to properly handle the current situation in accordance with the law".

Mr Kerry said the US supported universal suffrage in Hong Kong, adding he hoped local authorities would "exercise restraint and respect for the protesters' right to express their views peacefully".

In China, state TV said Hong Kong's police should be supported in their attempts to "restore the social order as soon as possible".

An editorial in the Chinese Communist Party's newspaper People's Daily on Thursday called the situation "chaos".

"Hong Kong has for many years enjoyed peace and harmony. It now sees the emergence of this embarrassing 'chaos', and the root cause lies with a few people who are disrespecting the law.... 'chaos' denies Hong Kong residents their prosperity, goes against their wishes, and is not what all Chinese people wish to see or what we can tolerate."

Juliana Liu, BBC News, Hong Kong

The senior Chinese leadership has set out clear limits on who can run for the position of chief executive, Hong Kong's top leader, in 2017.

The rules make it virtually impossible for anyone not trusted by the Chinese government to stand for election.

As a result, the protesters accuse Beijing of reneging on decades of vows to give Hong Kong people genuine democracy.

But although there is widespread anger that Beijing may have violated the spirit of the agreements it has made, there is intense debate over whether it has violated the letter of the law.

Read more: Did China go back on its promises?

On Wednesday, Lester Shum, the vice-secretary of the Hong Kong Federation of Students, said he hoped Mr Leung would resign within a day.

"Otherwise, we will announce an escalation of our movement, including occupying or surrounding different government buildings."

Image copyright AFP Image caption Protesters shield police from the rain in Hong Kong's so-called "umbrella revolution"

Chan Kin-man of Occupy Central urged the students to be peaceful, but also called on Mr Leung to quit, saying: "We can talk to anyone in the government except him... resign for the sake of Hong Kong."

Thousands of demonstrators remain camped out at the main protest sites in the Central business district, Causeway Bay and Mong Kok.

In other developments:

Mainland authorities have suspended bookings for tour groups to Hong Kong, the South China Morning Post reported

On Wednesday, several rallies supporting the protests took place around the world, including in Taiwan, London and Macau

Rights groups say some mainland-based activists have been detained

'A week or a month'

Several reports, citing unidentified Hong Kong sources, suggest the authorities plan to wait, hoping the protest campaign will lose momentum.

The Wall Street Journal quoted a Hong Kong source as saying that Mr Leung was planning to ride out the rallies and had been ordered by Beijing not to use violence.

Media playback is unsupported on your device Media caption Ali Moore: Have Hong Kong protests hit the shopping industry?

A Hong Kong government source told Reuters: "It may take a week or a month, we don't know. Unless there's some chaotic situation, we won't send in riot police... we hope this doesn't happen."

Speaking to the BBC, former Hong Kong Governor Chris Patten accused China of breaching commitments it made to Hong Kong before taking over sovereignty from the UK in 1997.

But he said he did not believe China "would be so stupid as to do anything like sending in the army."

Hong Kong democracy timeline

1997: UK gives Hong Kong back to China under a 1984 agreement giving it "a high degree of autonomy" for 50 years

2004: China says it must approve any changes to Hong Kong's election laws

June-July 2014: Pro-democracy activists hold an unofficial referendum on political reform. Both sides hold large rallies

31 August 2014: China says it will allow direct elections in 2017 but will pre-approve candidates

22 September 2014: Student groups launch a week-long boycott of classes

28 September 2014: Occupy Central and student protests join forces and take over central Hong Kong

2017: Direct elections for chief executive due to take place

2047: Expiry of current agreements

Q&A: Hong Kong's democracy controversy