Media playback is unsupported on your device Media caption Pro-democracy activists forced their way through a police cordon to break into the government's headquarters, as Anbarasan Ethirajan reports

At least 100 pro-democracy protesters have pushed through a police cordon to break into the main government compound in Hong Kong.

The break-in occurred just before 22:30 local time (15:30 BST), as protesters scaled security fences to get inside.

Police used pepper spray to disperse the crowd and six people were detained.

Students and activists have been protesting against a decision by Beijing to rule out fully democratic elections in Hong Kong in 2017.

The attempt to storm the government building came towards the end of a week of demonstrations that has seen thousands of college and university students boycott their classes.

The protesters smashed barriers and scaled fences to occupy a forecourt outside government headquarters.

Hundreds had also gathered outside the compound chanting "shame on the police", the South China Morning Post newspaper reports.

But police managed to restore a cordon around the building's forecourt by late on Friday night.

Some of the protesters were later allowed to leave after their personal details were recorded, local media reported.

Police accused the protesters of endangering public safety, saying they had "posed a danger to themselves and other people".

Image copyright AFP Image caption Only a few dozen protesters are thought to still be in the forecourt, with many more beyond the cordon

A statement said five men and one woman were arrested. One police officer suffered a shoulder injury.

"Members of the public should comply with the laws of Hong Kong and maintain social order when expressing their views," the statement said.

The South China Morning Post paper describes the forecourt as a popular protest spot, to which access has been restricted since July.

Earlier on Friday, hundreds of secondary school students joined the protest, many of them defying their parents.

On Thursday, about 2,000 university students held a night-time protest at the house of the Hong Kong leader, Chief Executive CY Leung.

The students' boycott is seen as a prelude to a larger demonstration planned for 1 October, organised by pro-democracy group Occupy Central, which has vowed to block the financial district.

Hong Kong operates under a "one country, two systems" arrangement with Beijing, which means citizens are allowed the right to protest.

In August, Beijing decided that candidates for the 2017 chief executive election would first have to be approved by a nominating committee. Activists have argued that this does not amount to true democracy.

Hong Kong democracy timeline

1984: Britain and China sign an agreement where Hong Kong is guaranteed "a high degree of autonomy, except in foreign and defence affairs" for 50 years following the handover in 1997.

2004: China rules that its approval must be sought for changes to Hong Kong's election laws.

2008: China says it will consider allowing direct elections by 2017.

June-July 2014: Pro-democracy activists hold an unofficial referendum on political reform and a large rally. This is followed by protests by pro-Beijing activists.

31 August 2014: China says it will allow direct elections in 2017, but voters will only be able to choose from a list of pre-approved candidates. Activists stage protests.

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

Q&A: Hong Kong's democracy controversy