In a typically freewheeling speech to the annual conference of the International Association of Chiefs of Police that lasted more than an hour, Mr. Trump struck a stern law-and-order tone as he lashed out at the city’s police chief, condemned local gun violence, railed against illegal immigrants, and denounced an apparently staged assault on the actor Jussie Smollett.

Mr. Trump said that Mr. Smollett, who made a questionable claim last year that he was assaulted in Chicago by Trump supporters in red “Make America Great Again” hats, “beat himself up.” (Mr. Smollett was charged with filing a false police report before the charges against him were dropped as part of a deal with prosecutors.)

Mr. Trump drew an unlikely line between Mr. Smollett’s alleged hoax and the House Democratic inquiry now underway against him back in Washington.

“It’s a scam, just like the impeachment of your president is a scam,” Mr. Trump said.

Mr. Trump did not explain how exactly his predecessors had failed in their pursuit of Mr. al-Baghdadi. The ISIS leader was imprisoned by American forces in Iraq in 2004, during the administration of George W. Bush, but was seen as an insignificant figure at the time. He was released after less than a year and then dropped out of view for several years. United States officials did not appreciate his import as an insurgent leader until 2009, early in the administration of President Barack Obama.

Mr. al-Baghdadi became a top target of American forces deployed by Mr. Obama to Iraq and Syria after he led ISIS’s seizure of large swaths of territory in those countries in 2014. And United States officials say that Mr. Trump’s abrupt withdrawal of American troops from northeastern Syria earlier this month had complicated planning already underway for the treacherous raid on Mr. al-Baghdadi.