BRENTWOOD, N.Y. — Hours after another defeat at the hands of the Republican-held Senate, President Trump launched into a speech about immigrant gang violence on Friday and wound up delivering a de facto campaign rally with a spray of Long Island police officers applauding behind him.

In his second brief appearance in his home state since taking office — this time in a small auditorium at the Suffolk County Community College in Brentwood — Mr. Trump described cities as “bloodstained killing fields” that were overrun with undocumented immigrants before his inauguration in January. He described the perpetrators of violent crimes as “animals” and said his administration seeks to “dismantle, decimate and eradicate” gangs.

He also used his roughly 30-minute speech to bolster the police, urging them to be less “nice” in arresting immigrant criminal suspects or gang members whom he described as enraptured by slow torture of their victims. The gang La Mara Salvatrucha, or MS-13, has been accused of a string of heinous gang murders on Long Island.

As expected, Mr. Trump called on Congress to fund hiring 10,000 more Immigration and Customs Enforcement agents to crack down on undocumented immigrants in the United States, including those he said pose a criminal threat, and added that the initial spending for his proposed wall on the Mexico border was just approved by the House.