HONG KONG—Voters delivered a resounding defeat to the government and a major show of support for the protest movement, as millions turned out for local elections that became a referendum on the mood of the city.

The outcome will put more pressure on the government to negotiate with protesters demanding an investigation into police violence and democratic elections for the city’s legislature and chief executive, the city’s top leader. It was also a rebuke to Beijing, which has pushed the city to crack down on the protests....