Tanks, missile launchers and chanting troops greeted President Xi Jinping in a potent display of Chinese military might Friday as part of his landmark visit to politically divided Hong Kong .
The show of force came hours after activists were released from police custody following their arrest over a protest.
Xi arrived in the city on Thursday to mark 20 years since Hong Kong was returned to China by Britain, with authorities desperate to stick to the script during anniversary celebrations.
A huge security operation has shut down large parts of the city, with thousands of police deployed to keep away demonstrators angry at Beijing's tightening grip on the freedoms of nearly eight million people.
Xi inspected troops at China 's People's Liberation Army airfield in rural northern Hong Kong , wearing a black Mao suit and riding an open-top camouflage jeep in the largest military parade since the 1997 handover.
As the jeep slowly drove past row upon row of air, naval and land personnel, Xi shouted "Hello comrades!" as the troops responded "Hello chairman!"
Armoured vehicles topped with missile launchers and military helicopters lined Xi's path along the airstrip for the eight-minute extravaganza.
Members of the public waved flags from packed stands and were given gift bags including a camouflage cap, water and snacks in the blazing heat.
Press were issued a notice ahead of the event barring them from bringing an eclectic list of items, including make-up, deodorant, plants, animals, opium and heroin.
There were fears that the PLA would crack down in Hong Kong when it was returned to China , particularly after the brutal crushing of student protests in Beijing's Tiananmen Square in 1989, but it has kept a very low profile.
Friday's parade was a rare display.
- Police action -
The PLA is responsible for defending the city and comprises only mainland troops, with Hong Kong residents unable to serve, but it is barred from interfering in local affairs.
A banner behind the troops read "Fully implementing 'one country, two systems', this great policy", referring to Hong Kong 's semi-autonomous set-up.
As part of the handover deal, Hong Kong was guaranteed rights including freedom of speech and an independent judiciary for 50 years, but there are concerns those liberties are disappearing as Beijing becomes ever more assertive.
Xi's three-day visit is his first since becoming leader in 2013, and comes three years after huge pro-democracy rallies crippled Hong Kong .
Student protest leader Joshua Wong and young legislator Nathan Law were among those detained by police Wednesday night for "public nuisance" over a protest a stone's throw away from the hotels where Xi and his entourage are staying.
The 26 activists arrested were released from police custody in the early hours of Friday after threatening to go to the High Court to petition against their ongoing incarceration.
Police told AFP they had not been charged, but bailed to report back in September.
Activists say they have been followed by police and "thugs" since the protest.
In many major Hong Kong newspapers, coverage of protests was eclipsed by exhaustive accounts of Xi's itinerary and quotes from him, at a time when the media stands accused of succumbing to pressure from Beijing.
The US State Department urged China to respect civil liberties in Hong Kong , including press freedom, in a statement Thursday.
In public comments during his trip, Xi has pledged support for Hong Kong and reassurance that its semi-autonomous system of government is in tact.
But he also praised the government for "dealing a blow" to an independence movement that has infuriated Beijing.
Calls for the city to break away from China grew out of the failure of the mass pro-democracy rallies in 2014 to win political reform.
Xi will attend a banquet at the harbourfront convention centre Friday night, followed by a variety show, with pro-democracy and pro-independence groups expected to protest outside the venue and across the harbour.