Richmond Police Chief Chris Magnus, who gained nationwide attention for holding a sign reading “Black lives matter” at a peaceful protest in his city, was criticized by his department’s rank-and-file Friday for doing so in uniform.

The Richmond Police Officers Association said members were not upset by the message, but by the fact that Magnus was wearing his uniform when he attended a Tuesday demonstration on Macdonald Avenue. The message on his sign is one of the rallying cries that emerged after grand juries in Missouri and New York declined to indict white police officers for killing two unarmed black men.

The union said the chief’s actions violated the state’s Government Code, which states that “No officer or employee of a local agency shall participate in political activities of any kind while in uniform.”

Alison Berry Wilkinson, an attorney for the Richmond police union, said Friday that the chief, like anyone else, has a First Amendment right to free speech. But state law explicitly bars him from sending a message while in uniform.

“Police chiefs are not above the law,” Wilkinson said. “While many may admire the chief for proactively engaging with the community on one of the most significant political issues of the day, by doing so in uniform he violated the very laws he is sworn to uphold.”

She said Richmond police officers “enforce the laws of this state without passion or prejudice, and are disappointed the chief felt free to flaunt those laws by wearing his uniform during the protest.”

Magnus and several other police officers, including Deputy Chief Allwyn Brown, who was also in uniform, gathered outside a community center along with 150 others. Wilkinson said Brown’s “role is less clear. Not certain he was a participant in the protests. If he was there to monitor, then that would be proper.”

Magnus said Friday, “When did it become a political act to acknowledge that 'black lives matter’ and show respect for the very real concerns of our minority communities? This should not be about 'us versus them.’ It should be about finding ways to build bridges and address the schism that exists between many of our residents and police.”

Wilkinson countered, “If his officers did the same thing, on either side of the issue, they would be disciplined.”

This isn’t the first time that Magnus has reached out during a tense time for police-community relations.

After Richard Perez, 24, was shot and killed by a Richmond police officer at a liquor store in September, the chief reached out to the community on Facebook. Magnus and Brown were invited by Perez’s family to his memorial service.

Henry K. Lee is a San

Francisco Chronicle staff writer. E-mail: hlee@sfchronicle.com Twitter: @henryklee