President Trump vowed to defend police against "dangerous" and "malicious" attacks and to push for an immigration system that focuses on the merits of applicants during a wide-ranging speech at the FBI Academy on Friday.

"America's police will have a true friend and loyal champion in the White House — more loyal than anyone else can be," Trump said at the academy's graduation ceremony, at which state and local police officers celebrated the completion of a 10-week law enforcement course.

"You very rarely get the recognition you deserve," Trump said.

"Being a police officer is not just a career, it's a calling," he added. "They have been subjected to malicious attacks on their character, on their integrity."

Trump pointed to the rise in violence in cities around the country while calling on society to stop its demonization of police officers, which has arisen in part from what critics say is a rise in violence against unarmed blacks.

"What the hell is going on in Chicago? What the hell is happening there?" Trump said of the violence in Chicago that kills hundreds every year.

"We believe criminals who kill police officers should get the death penalty," Trump added.

The president also called for reforming an immigration program that randomly selects applicants to enter the U.S. every year.

"They give us their worst people, they put them in a bin," Trump said of the diversity visa lottery program.

"What kind of a system is that? They come in by lottery," he added. Administration officials have taken aim at the visa lottery since a beneficiary of the program drove a van into a crowd of people on a New York City sidewalk on Halloween, killing eight people.

The suspect in an attempted bombing of the New York City subway system earlier this week reportedly entered the country through "chain migration," a process by which immigrants already in the U.S. can sponsor family members to enter the country, who can then in turn sponsor more family members, creating a chain of immigrants.

Trump also used his speech to highlight efforts to crack down on MS-13, a criminal gang with some members who traveled to the U.S. illegally and who have committed a number of violent and occasionally brutal crimes around the country.

"To any member of MS-13 listening, I have a message for you: We will find you, we will arrest you, we will jail you, we will throw you the hell out of the country," Trump said. "Somehow, I like it better than jail. Jail, we have to take care of them. Who the hell wants to take care of them? You know, the jail stuff is wonderful, but we have to pay for it, right?"