San Francisco Supervisor Sandra Lee Fewer stepped to the microphone at an election night party for progressive district attorney candidate Chesa Boudin and unleashed a tirade against the city’s nearly 2,000-member police union: “F— the POA! F— the POA! F— the POA!”

The profane chant Tuesday night about the city’s Police Officers Association spread on social media as witnesses documented the outburst in which Fewer raised her middle fingers while flanked by some of the city’s notable progressive leaders. Behind her were Supervisors Matt Haney and Hillary Ronen, as well as former Supervisors Jane Kim and David Campos.

Police union President Tony Montoya fired back Wednesday, sending Fewer a letter demanding an apology and calling her words “worrisome and completely unacceptable and unbecoming of someone elected to represent all San Franciscans.”

The “unhinged attack,” he wrote, “made our officers’ job more dangerous.”

Fewer sought to clarify her rant on Wednesday, apologizing to the officers in the Police Department in an open letter but doubling down on her ill feelings toward the union’s leadership, saying the “organization has and continues to incite fear in our city.”

“I apologize if my comments were misinterpreted to be an attack on you, as individual officers,” Fewer wrote. “That could not be further from the truth. I know and understand how difficult the job is and am deeply appreciative of your service.

“Yes, I used profanity in my comments about the POA,” Fewer said, “but quite frankly, I don’t think it is language that we have not heard before.”

Her chant and the reaction laid bare the acerbic relationship between the city’s progressive wing and the police union, which further deteriorated after the union spent $660,000 funding attack ads against Boudin in the days leading up to the election. One ad accused Boudin of being “the #1 choice of criminals and gang members.”

As votes were still being counted Wednesday in the neck-and-neck race between Boudin and Suzy Loftus, who was appointed district attorney by Mayor London Breed just weeks before the election, Fewer’s words increased hostilities between city progressives and law enforcement, which likely will continue if Boudin is elected.

“The civility in politics went out the window in San Francisco a long time ago,” said political analyst David Latterman. “If Chesa wins, law enforcement and the district attorney’s office are going to be at war. It’s going to be a very, very bad scene here for a long time.”

Boudin, an attorney in the public defender’s office, said he was not in the room when the chant started and was “surprised to hear it.” He added, “I think the chant was an expression of the frustration that so many San Franciscans, including many of our elected officials, feel with the POA’s electioneering tactics.”

Campos, a former police commissioner, distanced himself from Fewer’s actions.

“I have my issues with the POA, but that response is kind of childish and minimizes the seriousness of the issues we have with them,” he said. “There have been a number of officer-involved shootings where people have died. That’s a serious thing for me.”

Conflict between the Police Officers Association and the district attorney’s office is nothing new. George Gascón, who stepped down last month as district attorney, was famously at odds with the union over his effort to investigate police abuses as well as progressive reforms, like Proposition 47, which reduced some property and drug crimes to misdemeanors. Gascón had been San Francisco’s police chief before he became district attorney.

The union has resisted reforms in the department following a number of fatal officer-involved shootings that prompted the resignation of union-friendly Chief Greg Suhr. The union pushed a controversial measure to arm officers with Tasers, which would have overruled a policy passed by the Police Commission, and the group sued the city over a policy barring cops from shooting at moving vehicles.

“It was really bad with the POA when George Gascón was district attorney,” said Max Szabo, Gascón’s former spokesman. “They spent hundreds of thousands smearing him and were very much against the reform he stood for.”

Loftus also clashed with the union while serving as president of the Police Commission and working to reform the department. Even as Loftus and Boudin began to emerge as the front-runners in the race, the union refrained from endorsing either candidate.

Since becoming president of the union in May 2018, Montoya has sought to improve relations with city leaders. He’s met privately with members of the Board of Supervisors and fired incendiary consultant and former union President Gary Delagnes over a Facebook rant attacking late Public Defender Jeff Adachi.

Boudin ran a campaign focused on holding police accountable in use-of-force cases and was the only candidate who said he would have charged officers in the 2015 fatal shooting of Mario Woods in the city’s Bayview. He has also said he would not charge quality-of-life crimes, like public camping and urination, and has emphasized rehabilitation over incarceration.

His message secured support from the city’s outspoken progressives like Fewer, who has often sparred with police.

While serving on the board’s Budget and Finance Committee in June 2018, Fewer cut funding for police Tasers after the Police Commission voted to arm officers with the weapons. She also held a hearing to eliminate the city’s gang injunction program and has been against building a jail to replace the dilapidated facility at the Hall of Justice.

Fewer often invokes her husband, John Fewer, a sergeant who retired from the Police Department in 2012, to bolster her credibility on law enforcement issues.

In her letter Wednesday, Fewer wrote, “My husband served for 35 years as a San Francisco police officer and is a five-time Medal of Valor recipient.” She said, “As a family who has paid POA membership dues for 35 years, I cannot stay silent and condone the behavior of the organization’s leadership.”

A Chronicle investigation published in 2006 found that John Fewer had been the subject of complaints over his use of force. In a nine-year period, Fewer reported using force 24 times. One man said Fewer lifted up his eyelids and shot pepper spray into his eyes.

“Since my husband retired in 2012, we as a society have learned a lot about policing and how to prevent officer use of force,” Sandra Fewer wrote Wednesday in a statement to The Chronicle. “Through my husband’s experience, I have learned that de-escalation and crisis intervention training are critical and positive steps towards 21st century policing, and I wish that these tools were available to him and his fellow officers during his time of service.”

Evan Sernoffsky is a San Francisco Chronicle staff writer. Email: evan.sernoffsky@sfchronicle.com Twitter: @EvanSernoffsky