HONG KONG — Thousands of Hong Kong’s civil servants demonstrated against the government after work on Friday evening, sending a powerful message of discontent by joining the anti-government protests that began in early June.

Despite warnings from the government about their participation, the civil servants overflowed the streets outside Chater Garden, a downtown park.

Organizers estimated that more than 40,000 people participated, including protesters who do not belong to the Civil Service. The police said that at its peak there were about 13,000 people at the demonstration.

Joseph Wong, a retired government official who once led the Civil Service, urged the city’s leader, Carrie Lam, to be responsive to the public’s anger. “If we think today’s officials, today’s chief executive, violated or failed to follow the rule of law, as civil servants and as civilians, we have a duty to point it out,” he said at the rally.