During a speech on Long Island on Friday, President Donald Trump took a break from discussing gang violence and illegal immigration to give the law enforcement officers gathered for his remarks some advice on how to treat suspects.

"When you guys put somebody in the car and you're protecting their head, you know, the way you put their hand over?" Trump said, miming the physical motion of an officer shielding a suspect's head to keep it from bumping against the squad car.

"Like, don't hit their head, and they just killed somebody - don't hit their head," Trump continued. "I said, you can take the hand away, OK?"

These remarks, coming after Trump talked about towns ravaged by gang violence and described "these thugs being thrown into the back of a paddy wagon," met with applause from at least some of the law enforcement officers gathered for his speech at Suffolk County Community College in New York.

A group of uniform officers standing behind Trump applauded, and, when he turned to face them, some smiled and appeared to chuckle.

In response to a question regarding Trump's comments and the officers who applauded, the Suffolk County police quickly distanced the department from Trump's comments, saying Friday that they would not accept this treatment of people in custody.

"The Suffolk County Police Department has strict rules and procedures relating to the handling of prisoners, and violations of those rules and procedures are treated extremely seriously," the department said in an emailed statement. "As a department, we do not and will not tolerate 'rough[ing]' up prisoners."

Trump's remarks also drew a rebuke from the International Association of Chiefs of Police. In a statement, the group did not specifically mention Trump by name but appeared to respond to his speech by stressing the importance of treating all people, including suspects, with respect.

"Managing use of force is one of the most difficult challenges faced by law enforcement agencies," the group said. "The ability of law enforcement officers to enforce the law, protect the public, and guard their own safety, the safety of innocent bystanders, and even those suspected or apprehended for criminal activity is very challenging.

"For these reasons, law enforcement agencies develop policies and procedures, as well as conduct extensive training, to ensure that any use of force is carefully applied and objectively reasonable considering the situation confronted by the officers," the statement continued.

Trump's comments were made during a dark, foreboding address largely focusing on the transnational gang MS-13. He also peppered his speech with expressions of support for police, echoing his efforts both during and since the presidential campaign to portray himself as a champion of law enforcement.

These remarks were condemned by civil rights and advocacy groups. Vanita Gupta, who ran the Justice Department's civil rights division during the Obama administration, decried the comments and said they ran counter to efforts from local police agencies to repair relationships with their communities.

"Trump's remarks today are unconscionable," Gupta, who is now president and chief executive of the Leadership Conference on Civil and Human Rights, said in a statement. "The President of the United States, standing before an audience of law enforcement officials, actively encouraged police violence. His remarks undermine the positive efforts of local law enforcement agencies and communities around the country working to address police misconduct and build community-police trust."

Janai Nelson, the associate director-counsel NAACP Legal Defense and Educational Fund, said Trump's comments "encouraging police officers to disregard the safety of individuals in their custody rises to a new level of danger."

"We need law enforcement who do not share the Trump Administration's outdated and unlawful views to promote protecting the rights and safety of all Americans by condemning those who condone impunity among law enforcement," Nelson said in a statement.

The American Civil Liberties Union posted on Twitter that Trump was "urging lawlessness" with his speech.

Trump has previously encouraged violent behavior during public remarks, particularly during his raucous presidential campaign rallies. At a November 2015 rally in Alabama, Trump said that a protester was loud and "maybe he should have been roughed up."

During another campaign rally in Michigan, Trump said he would defend in court anyone who hurt a protester being escorted out. When a protester interrupted a Las Vegas rally, Trump said "guys like that" used to be "carried out in a stretcher," adding: "I'd like to punch him in the face, I tell ya." At another rally, Trump said protesters were being removed too slowly because "nobody wants to hurt each other anymore."

With his comments Friday, Trump appeared to encourage police officers not to worry about using excessive force during arrests.

Officers can be arrested and charged with excessive force, facing charges on both a local and federal level. Several Suffolk County police officers were indicted last year and accused of beating a suspect after he was arrested in 2012. In November, a week before Trump was elected, the former Suffolk County police chief was sentenced to 46 months in prison after pleading guilty to a federal civil rights violation and conspiring to obstruct justice; authorities said he beat a man handcuffed and in police custody.

The Justice Department said its investigations of unconstitutional behavior by law enforcement officers most frequently involve allegations of excessive force. If a person alleging excessive force has been arrested or detained, federal officials must prove that an officer used more force "than is reasonably necessary to arrest or gain control of the victim," the Justice Department states.

In 2016, a former Las Vegas police officer was charged with violating the civil rights of an unnamed person by using excessive force during an arrest; the indictment specifically notes that among other things, the officer slammed the person's head into the door of his police car.

Such charges have continued during the Trump administration. Last month, the Justice Department announced that three current and former Florida police officers had been indicted in connection with the assault of a car passenger during a traffic stop. Officers charged with using excessive force during arrests have also faced charges of making false statements about what unfolded.

Excessive force lawsuits can also be costly for local governments. Last month, a $225,000 settlement was reached in the case of a Pennsylvania man who said he was shocked with a Taser after arguing with an officer during his arrest. In 2015, a $1 million settlement was reached in a case involving a California sheriff's deputy accused of using excessive force on a man with Down syndrome.

Trump and his administration have offered a defense of law enforcement officers in the face of what they have portrayed as an anti-police mentality. Attorney General Jeff Sessions tied a recent increase in violent crime to "undermined" respect for police.

Sessions's Justice Department has also launched a review of all police-reform agreements in place nationwide, pacts that remain a key legacy of former president Barack Obama's administration. Such agreements are typically reached after expansive federal civil rights investigations, such as the probe of the Chicago police, released days before Trump took office, which determined that officers there routinely use excessive force and violate the rights of residents.

Before he was confirmed, Sessions said that consent decrees forcing reforms on departments can "undermine the respect for police officers." In April, the Justice Department said that officials would review all existing agreements to ensure they do not work against the Trump administration's goals of fighting violent crime while protecting officer safety and morale. Police departments have vowed to continue pushing for reforms.

During his speech Friday, Trump also returned to a familiar theme for him: invoking, and questioning, the levels of violence in Chicago. Speaking in New York, Trump appeared to tell a variation on a story he shared last year about an unnamed "top police officer" in the city who could stop the bloodshed there in a matter of days.