Robert Peralta’s life was derailed by a single Facebook comment.

When the San Franciscan saw a well-known local activist had posted about being “choked” and “slammed” by a sheriff’s deputy at city hall, Peralta fired off a short response: “Wow, brother they wanna hit our general. It’s time to strike back. Let’s burn this motherfucker’s house down.”

Peralta, a 35-year-old activist and musician, didn’t think twice about the 23 January Facebook thread until two months later, when he learned that police had issued a warrant for his arrest – accusing him of threatening to kill law enforcement.

“Why waste all of the county’s money on this?” said Peralta, who turned himself in and was booked into jail, despite having no criminal record. “You’re going to take me to jail … for Facebook?”

Peralta’s felony criminal case is part of what civil rights campaigners say is a disturbing trend of police and prosecutors targeting activists for social media posts, arresting users over innocuous political messages that constitute free speech.

“For a country that purports to be guided by democracy and guided by civil rights, this is a very dangerous and very slippery slope,” said Malkia Cyril, the executive director of the Center for Media Justice. “Black activists are expressing anger, rage, hatred even about the conditions that threaten their daily lives, and they are being held liable for how they express that anger, even though they’ve committed no crime.”

Peralta’s charges have come at a time of heightened concerns about threats against law enforcement following a number of police killings – most notably a Dallas shooter who shot five officers last year. Donald Trump has also lamented a so-called “war on police”, and there has been a wave of “Blue Lives Matter” bills seeking to classify police as a protected class. Government statistics, however, suggest there is no surge in violence against police.

Critics say that digital surveillance is also plagued by racial biases, with law enforcement devoting significant resources to spying on specific activist communities, while ignoring complaints from minorities and women who face violent online abuse.

When Peralta commented on the Facebook post about alleged police violence in January – which included a photo of the officer’s arms around the activist’s neck – he said he knew nothing about the identity of the law enforcement official.

“On Facebook, you comment on so many things in minutes,” he said in a recent interview. “I didn’t even mean it.”

[[{“type”:”media”,”view_mode”:”media_original”,”fid”:”623197″,”attributes”:{“alt”:””,”class”:”media-image”,”height”:”59″,”typeof”:”foaf:Image”,”width”:”478″}}]]

Robert Peralta’s Facebook post. Photograph: Facebook

He later learned that an investigator had obtained a search warrant for his Facebook and was able to comb through his personal account.

Peralta thought it was a simple misunderstanding he could clear up by talking to police. But instead, prosecutors jailed him, saying the threat was “made so unequivocally, unconditionally, immediately and specifically as to convey to the person threatened a gravity of purpose and an immediate prospect of execution”.

His bail was set at $25,000.

“In jail, you just want to get out. You can’t deal with the environment,” he said. “I was not feeling like I was treated like a human.”

A friend helped Peralta post an initial $750 payment on the bail so he could be released, and eventually prosecutors agreed to dismiss the charge in exchange for Peralta giving a presentation to youth about responsible social media use.

Although he is on track to have the case wiped from his record, the prosecution has taken a serious toll on his life, Peralta said. He is still on the hook for $2,500 and is now paying monthly installments that are difficult to afford, given that he has a fixed income from disability payments. The sheriff’s office also seized his phone, which has his music on it, and won’t return it until the case is formally dismissed later this year.

“I’m still dealing with the repercussions,” he said.

A spokeswoman for the sheriff’s office noted that Peralta apologized to the deputy, adding, “It’s an excellent resolution to the case.”

Alex Bastian, spokesman for the San Francisco district attorney’s office, which prosecuted the case, noted that family members of the deputy had reported Peralta’s Facebook comment. He added in an email: “The first amendment is very sacred to us. At times, people make statements that infringe on another’s freedom to live free from fear. We are always striving to find the right balance between those two important considerations.”

Activists said Peralta’s story is not unique. After the Dallas police shootings last year, there was a spike in arrests across the country of people who criticized police on Facebook and Twitter, according to the Intercept. In March, police won a warrant to search a Facebook page of a Dakota Access pipeline protest group, leading to an ACLU challenge.

Chris Wahmhoff, a 38-year-old Michigan activist who was convicted of a felony for an oil pipeline protest action, got into trouble last year when he criticized governor Rick Snyder on Facebook amid the Flint water crisis, writing: “So when y’all are ready to march in and take his ass across the street, I have my torch, I got warm socks. I’m waitin on y’all … ”

[[{“type”:”media”,”view_mode”:”media_original”,”fid”:”623199″,”attributes”:{“alt”:””,”class”:”media-image”,”height”:”127″,”typeof”:”foaf:Image”,”width”:”589″}}]]

Chris Wahmhoff’s Facebook post. Photograph: facebook

The comment led to a probation violation charge for “threatening behavior”, even though Wahmhoff insisted that he was trying to argue for the governor’s arrest – that he be taken from his office across the street to the police department.

“I really felt we should have marched and did whatever we needed to do – non-violently – to get him in jail,” Wahmhoff said in a recent interview, adding that he felt his Facebook was targeted because of his previous protests. “They come after you if you become an activist just for the needs of control. They are going to keep pushing. It’s as simple as a bully.” The charge was later dropped.

Landon Davis, a San Francisco public defender, noted that the courts have granted citizens broad protections to criticize public officials, even if the comments are repulsive or shocking. Davis recently represented a man accused of making racist threats against a black police chief on Twitter, but ultimately convinced a judge to drop the charge on free speech grounds.

“As offensive as his statements were, if you look at the entire context, it was completely political,” said Davis, who is black.

Sometimes when police allege threats, Davis said, it seems they lack any evidence of danger and are simply pursuing charges because they were offended by the comments: “They use that as a basis to prosecute someone either they don’t agree with or don’t like … It can have a huge chilling effect on people’s expression online.”