HONG KONG — Crowds of masked prodemocracy demonstrators in Hong Kong defied official warnings, set fires in the streets and battled the police on Saturday in the most intense clashes since protests over the city’s fate began in June.

As government helicopters hovered above, the riot police fired tear gas, pepper spray and water cannons at protesters outside government offices and the Chinese military’s local headquarters. Some in the crowd threw firebombs at police barricades.

The police pumped blue-dyed water into knots of protesters, starkly marking them to make it easier for officers to make arrests. And by nightfall, a makeshift barricade that protesters had erected across a road had been set on fire, sending a plume of black smoke through canyons of skyscrapers and blinking neon signs.

[City on edge: Photographs from Hong Kong’s summer of protest]

Tensions had been running high, partly because the protests marked the fifth anniversary of the day the Chinese government rejected proposals for fully democratic elections in favor of a more limited voting plan in this semiautonomous former British colony. That decision angered many in Hong Kong, and it set off months of large-scale protests in 2014 known as the Umbrella Movement.