Image copyright EPA Image caption Some protesters had chained themselves to the sculpture on Wednesday night

Hong Kong police have released several activists detained for staging a protest ahead of the territory's handover anniversary.

The city is holding a series of lavish events to mark 20 years since it was handed back to China by Britain.

Chinese President Xi Jinping is in Hong Kong and inspected troops at a local garrison on Friday morning. He is expected to attend a banquet later.

Security is tight with large protests planned amid a tense political climate.

On Wednesday, pro-democracy activists including student leader Joshua Wong and legislator Nathan Law surrounded and climbed into a golden sculpture of a bauhinia flower, Hong Kong's emblem.

Media playback is unsupported on your device Media caption Student leader Joshua Wong was dragged away by police officers

The sculpture, which sits by the city's harbourfront, was a gift from China and an iconic landmark symbolising the handover.

Police later arrested the 26 activists, who were calling for greater political freedoms and protesting against the perceived growing influence of Beijing. They also called for the release of terminally ill Chinese dissident Liu Xiaobo.

The political party Demosisto, founded by Mr Wong and Mr Law, said on its Twitter account on Friday morning that all its arrested members were released.

Mr Wong tweeted that he was detained for "breaking the 'public nuisance' law".

Police said in a statement the activists had been released on bail and must report back to police in September. They have not been charged, reported AFP news agency.

Their protest was the second one this week at the monument - activists had earlier draped a large black flag over the sculpture and were stopped by police.

Analysis - Juliana Liu, BBC News, Hong Kong correspondent

Image copyright Reuters Image caption Mr Xi inspected troops at a Hong Kong garrison on Friday morning

It did not take long for President Xi to address the elephant in the room.

At a gathering of top Hong Kong officials, he praised the government for its handling of what he described as major political and legal issues, including effectively curbing the Hong Kong independence forces.

The movement is not mainstream.

In fact, opinion surveys show young people are less supportive of independence than they were just a year ago.

But the fact that the campaign exists at all is deeply worrying for Mr Xi.

His remarks were widely covered by Hong Kong media. Oddly though, the official Chinese news agency Xinhua's report of this speech has omitted any mention of his reference to the independence movement.

It would seem the agency is censoring the Chinese president. The exact reason is unknown.

It is plausible that mentioning the independence movement in the context of the handover anniversary, billed as a time to revel in the success of the return of Hong Kong, would be considered highly embarrassing, at least for people in mainland China.

Several demonstrations, including the annual 1 July pro-democracy march, have been planned for this weekend.

There is growing concern that the Chinese central government is undermining Hong Kong's more politically liberal traditions, despite its promise to give it a high degree of autonomy under the "one country, two systems" principle.

The pro-Beijing camp is also planning its own protests.

Read more about Hong Kong since the handover:

A series of official celebrations will be held this weekend, as well as the inauguration of Hong Kong's incoming chief executive Carrie Lam.

Mr Xi gave a short speech on Thursday after his arrival where he pledged Beijing's support for Hong Kong, and later met with the city's outgoing leader Leung Chun-ying and other officials.