The details were chilling. On Friday, the Suffolk County District Attorney’s Office handed down charges against 96 members and associates of the MS-13 gang. The allegations included brutal murders using machetes, assaults, rapes, a large-scale drug-selling operation and widespread intimidation of immigrants on Long Island.

The indictments represent a significant step forward in bringing this group of transnational thugs to heel. They will also go some way toward stopping MS-13’s push to expand its efforts to the East Coast from its home bases in El Salvador and California.

Kudos to the federal, state and local law enforcement personnel who teamed up to deliver justice to the gang members. But there is someone else who, while not necessarily deserving a share of the glory involved in this prosecution, certainly deserves an apology from pundits who have been opining about the right way to think and talk about MS-13: namely, President Trump.

Throughout his presidency, the mainstream media and other bastions of elite opinion have sneered and tsk-tsked at the president for highlighting the MS-13 problem. They have accused him of overstating the threat, undermining efforts to root them out of immigrant enclaves, engaging in dehumanizing rhetoric about the group and generally using the issue politically to gin up support for his supposedly repressive and heartless efforts to curb illegal immigration.

Indeed, no less a personage that House Speaker Nancy Pelosi condemned Trump for referring to MS-13 members as “animals.” She also falsely claimed that the president had referred to all immigrants in such terms, when in fact, he was expressing outrage about the gang’s heinous activities.

But the Suffolk indictments demonstrate that Trump was right to bring attention to MS-13 — and that his characterization of these bloodthirsty criminals was more of an insult to the animal kingdom than to immigrants. And it’s likely that his interest in the issue helped spur the authorities to devote the resources needed for the investigation.

The critics blasted Trump for linking the gang’s activities with illegal immigration. They said Trump’s crackdown against illegal immigration would hinder the fight against the gang. And they insisted that ignoring the legal status of immigrants would help police deal with the gang.

But the critics were wrong — on all counts. This latest bust employed conventional law enforcement tactics, including wiretaps and surveillance as well as monitoring the gang’s social media activity. It wasn’t the product of community relations outreach promoted by liberals.

The left thinks the only way to deal with gangs is to stop efforts to enforce immigration laws and cease local cooperation with federal officials. But had the activists succeeded in turning Suffolk into a “sanctuary” county, that would have made the MS-13 task force’s work harder. It would have turned immigrant communities into no-go zones, where the gang members could continue to intimidate fellow immigrants, their primary victims, with impunity.

As New Yorkers learned in the 1990s when “broken windows” police policies helped curb crime, tolerating illegal behavior of any kind — including immigration crime — is always a formula for chaos and violence.

It’s true that only a small percentage of illegal immigrants are criminals of any kind, let alone gang members. But if most of the Democrats’ presidential candidates get their way and illegal ­immigration is essentially decriminalized, that will be a gift to transnational gangs like MS-13. Such gangs thrive on the sense that the authorities don’t care what is happening in neighborhoods where those who dwell in the shadows live.

The only way to deal with the sort of horrifying violence that MS-13 has committed is zero tolerance for gangs with foreign bases of operations, as well as to effectively shut down the flow of people and drugs between Central America and the United States. Whether or not you like the way Trump talks about the issue, he was right to focus on the threat from MS-13 and to prod law enforcement to act.

It’s liberal commentators who have treated the gang as a non-issue and still promote dangerous sanctuary policies who should apologize for their comments, not Trump.

Jonathan S. Tobin is editor in chief of JNS.org. Twitter: @JonathanS_Tobin