London Mayor Sadiq Khan. (Robert Stevens/AP)

The mayor of Hagerstown, Md., apologized Wednesday for his Facebook comments that upset many residents by referring to London’s mayor as a “terrorist.”

Sadiq Khan is the first Muslim elected mayor of the city of London. He approved protesters’ request to fly a provocative balloon over the city — a massive blimp shaped like President Trump wearing a diaper — to mark the president’s visit to Europe.

Robert Bruchey II, a car salesman who has been mayor of Hagerstown on and off since 1997, doesn’t hold back his opinions on Facebook. A vocal supporter of Trump, he often criticizes the targets of the president’s insults, such as his May 6 post about “Meet the Press” host Chuck Todd. Bruchey wrote on Facebook: “Chuck Todd talks about credibility. LOLOLOL….hows that (fake news) wire tapping thing going for you Todd?” When Eric Holder, U.S. attorney general under President Barack Obama, reportedly said he was considering running for president, Bruchey wrote: “Wait, can you do that from a prison cell?” referring to the president and his supporters’ tendency to talk about imprisoning political opponents.

Bruchey’s constituents in Hagerstown often debate his conservative views on the mayor’s Facebook page.

But Bruchey’s comment about Khan sparked unusually intense anger. Bruchey wrote that he didn’t blame Trump for canceling a previous trip to London, adding a link to an article about the blimp and the comment: “Who would want to visit with this terrorist leading London.” Then he pasted a photo of Khan.

It was unclear on which Facebook page Bruchey made the comments, but The Washington Post was sent images of his comments, which Bruchey confirmed were valid.

When a citizen accused Bruchey of Islamophobia for calling the Muslim mayor a “terrorist,” Bruchey wrote back, “This isn’t about him being Muslim, this is about him being a POS,” a profane acronym that he has also used for Sen. Kamala D. Harris (D-Calif.).

But by Wednesday night, Bruchey said he regretted his words. “It’s never okay to spout that kind of rhetoric. As a mayor myself, I know better. I actually dislike that very much when it gets done to me,” he said.

But he said he didn’t intend, by using Khan’s photo and calling him a “terrorist,” to dig at his religion. “This had nothing to do with religion or race,” he said.

Kalim Ahmed, the president of Hagerstown’s only mosque, saw it differently. American Muslims are on high alert for what Ahmed called “the T-word,” which is often used as an anti-Muslim slur. “This is something that to hear that a mayor is calling another mayor of a big city — the only reason we feel it has been used is because that person is Muslim,” he said.

Both Bruchey and Ahmed said the mayor had not reached out specifically to the local Muslim community, which Ahmed said numbers up to 800 people at Eid celebrations at the Islamic Society of Western Maryland. But Ahmed said Bruchey is welcome to the mosque to learn more about his Muslim constituents.

And Ahmed appealed to both American and Muslim values: “We have to go back to the civility which we cherished. . . . We established this nation as a shining hill,” he said. “The teaching of our religion is to keep struggling to be a better human being.”

Correction: An earlier version of this post said that Bruchey has been mayor of Hagerstown since 1997. While he first became mayor in 1997, he has served nonconsecutive terms.