CHICAGO — President Trump took the occasion of an address to a national conference of police chiefs here to tee off on the city’s police superintendent and highlight its ongoing challenges with crime, claiming that Afghanistan “is a safe place by comparison.”

The speech marked the latest instance of Trump attacking a city that he feels is politically unfriendly territory, following his sharp criticism last month of homelessness in San Francisco and Los Angeles, and his description this summer of Baltimore as a “disgusting, rat and rodent infested mess.”

Ahead of Trump’s appearance Monday at the gathering of the International Association of Chiefs of Police, Chicago Police Superintendent Eddie Johnson announced that he would not attend because he felt “it just doesn’t line up with our city’s core values.”

Trump seized on those comments early in his remarks, telling the crowd: “There’s one person who is not here today. This person should be here because maybe he could learn something.”

He then identified Johnson by name and cited his remarks about “values.”

“That’s a very insulting statement after all I’ve done for the police,” Trump said. “I’ve done more than any other president has done for the police.”

Claiming that Chicago’s violence is “embarrassing to us as a nation,” Trump took aim at Johnson in remarkably personal terms, saying Chicago’s police “are entitled to a police superintendent who has their backs and knows what he’s doing.”

Trump rattled off several statistics about crime in Chicago, the nation’s third-largest city, which had 561 homicides last year, according to police.

“Afghanistan is a safe place by comparison,” Trump said.

He also accused Johnson of valuing illegal immigrants and criminals more than law-abiding citizens.

“And frankly those values to me are a disgrace,” Trump said. “I want Eddie Johnson to change his values and to change them fast.”

In a news conference after Trump’s remarks, Johnson said that “facts matter,” highlighting the city’s efforts to reduce violence and homicides in recent years.

“We’ve had double-digit reductions in crime for the last three years,” Johnson said, adding that he disputed what he described as “the national narrative that Chicago is a city on fire.”

The city’s violence has drawn national attention and concern in recent years as it rose in 2016 to levels Chicago had not seen in two decades, though it has declined from that point. Since 2016 — when Chicago had more homicides than New York and Los Angeles combined — the city has had fewer homicides and shootings.

According to statistics tracked by the Chicago Tribune, 436 people had been killed in the city this year through Saturday, 46 fewer than a year earlier. More than 2,310 people had been shot as of Sunday, according to the Tribune’s database, down 223 from a year earlier.

Chicago, in particular, has been a recurring feature of Trump’s remarks and Twitter feed. When discussing Chicago’s crime, Trump has compared the city to Afghanistan on previous occasions. He has likened the city to “a war zone” and said, without elaboration, that the violence is “very easily fixable.” Trump has suggested that the problem is due to Chicago officials “being overly politically correct.” Trump has also suggested in the past, as he did Monday, that the federal government could step in and help Chicago. Federal officials are already on the ground in Chicago, with different task forces involving collaboration between local police and federal agencies.

After his remarks to the International Association of Chiefs of Police, Trump held a closed-door luncheon fundraiser at his name-branded high-rise hotel in downtown Chicago — where revenue has dropped since Trump’s political career took off, internal documents have shown.

Trump’s campaign and a Republican Party official said the event for 250 people would raise $4 million for the Trump Victory joint fundraising committee.

While Trump attended the fundraiser, protesters marched along a promenade across the Chicago River. Several demonstrators held signs, including one that read, “All Roads Lead to Putin” and another reading, “Do Us a Favor, Though” — a reference to Trump’s now-famous utterance to the president of Ukraine during a phone call in which he pressed for an investigation into former vice president Joe Biden and his son Hunter.

Margaret Mitchell, who teaches at the University of Chicago, said she was attending the protest “because I think we are in a really critical time in this country.”

“People need to wake up about the true erosion of our institutions and our civil life,” she said. President Barack Obama, who was long based in Chicago before winning the White House, “had exceptional intelligence and respect for all persons,” Mitchell said. “Obama was the president for all Americans. Trump is the exact opposite.”

During his speech to the police chiefs Monday, Trump repeated a variation of a story he’s told in the past, claiming that he spoke to “a really powerful, strong-looking” officer in the city years earlier who had told him police could fix the city’s violence “in one day, sir.”

Trump has told different versions of the tale before.

In 2016, during the presidential campaign, Trump said on Fox News that “a top police officer in Chicago” had told him he could stop the violence “in one week.”

Police officials said at the time that “no one in the senior command” met with Trump or his campaign. A few months after taking office in 2017, Trump told a story about meeting “a really respected officer” in Chicago who told him they could stop the violence in “a couple of days.” Later that year, Trump told a similar story and said the officer told him they could “stop it immediately.”

Asked about this on Monday, Johnson said the police department searched extensively for whoever this officer might be but “we were never able to identify him.”

“We spent a lot of time trying to identify this person,” Johnson said. “Because if there’s somebody that can stop crime in a day, then I would bow down to them and say bring it on.”

But this wasn’t going to happen, Johnson said.

“We’re all adults here,” Johnson said at a news conference. “If there were that person, they would solve the crime in this country, not just in Chicago. So that person doesn’t exist.”

Trump’s comments about Chicago have repeatedly prompted pushback from Johnson, a veteran of the Chicago police who ascended to the top job in 2016.

After Trump claimed during the presidential election that year that a “top police officer” had told him the violence could be stopped in a week, Johnson replied by saying: “If you have a magic bullet to stop the violence anywhere, not just in Chicago but in America, then please, share it with us.”

When Trump threatened in a tweet to “send in the Feds!,” Johnson responded by saying he had “no idea what he’s talking about.”

During his news conference Monday, Johnson also said that “after today, I’m not going to even comment on this anymore, because we have bigger challenges in this city than going back and forth.”

Wagner and Berman reported from Washington. Susan Berger in Chicago and Felicia Sonmez in Washington contributed to this report.