U.S. Customs and Border Patrol agent
© (AP Photo/Matt YorkA U.S. Customs and Border Patrol agent gathers information on four Guatemalan nationals, including two men and a pair of 12 and 13-year-old boys, Wednesday, July 18, 2018, in Yuma, Ariz. Thousands of families and unaccompanied children are continuing to cross the U.S. border in Arizona and California even after learning of the government's family separation policy upon apprehension.
If the Trump administration had its way, Ramon Arevalo Lopez and Oscar Canales Molina would have been either in detention or deported.

Instead, they were out on the streets - thanks to judges' orders - where, according to police, they and another illegal immigrant delivered an MS-13 gang beat-down to two high school students in New York.

All three of the illegal immigrants entered the U.S. in 2016 as unaccompanied alien children, meaning they crossed the border without parents - a status that earned them a quick release into the country, where they were quickly reunited with their family and began to live while awaiting deportations that never came.

For Homeland Security Department officials, it's the latest sign of a legal system that stymies their efforts to oust dangerous figures.

"One of the loopholes we are imploring Congress to close could have prevented this gruesome attack," said Katie Waldman, a Homeland Security spokeswoman.

The three illegal immigrants got into a melee outside a Burger King in Huntington Station, New York, one afternoon last week. One of the teens was stabbed in the back, according to local news reports.

Authorities didn't have a specific motive for the attack but said the victims were inside eating, saw the boys they knew from high school giving them menacing looks, and decided to leave.

The three illegal immigrants were found later with bloodstained hands and clothes, and their names popped up as MS-13 members in a check of a gang-records database.

Why they were in the country and out on the streets that day is one of the more bizarre twists of U.S. legal policy on illegal immigrants.

Mr. Arevalo Lopez showed up at a California border crossing three months shy of his 18th birthday in December 2016, during the second major wave of illegal immigration under President Obama.

Under the Trafficking Victims Protection Reauthorization Act and a Clinton-era court settlement, the Flores agreement, unaccompanied children traveling without parents are required to be processed by immigration authorities and quickly released to social workers, and from there to sponsors.

They are deemed unaccompanied even if they have family in the U.S., which Mr. Arevalo Lopez did. His mother and her partner, as well as a brother, lived in New York.

Under the law, Mr. Arevalo Lopez was quickly sent to live with them while his immigration case was pending. Thanks to a massive backlog in the immigration courts, his next court date is still more than two years ago.

He was an 18-year-old freshman at the local public school - at a time when most 18-year-olds are either seniors or in college.

Suffolk County has become a hotbed for Hispanic gangs in recent years, rivaling the Washington, D.C., area for homicides and extortion related to MS-13.

At some point, authorities say, Mr. Arevalo Lopez became involved with MS-13 - whether that happened before he arrived or whether he was recruited in the area. Authorities say both options are common, with the gang sometimes seeking to get members in the U.S. by having them pose as unaccompanied alien children, while those already in the U.S. make prime recruits.

Ten months after his arrival in the U.S., Mr. Arevalo Lopez was questioned and then arrested by U.S. Immigration and Customs Enforcement agents on suspicion of gang membership.

After several months in ICE custody, attorneys asked an immigration judge to release him on bond. When that was refused, the lawyers went to federal district court.

In June a 95-year-old federal judge - Robert W. Sweet, who has been sitting on the bench since the Carter administration - ordered Mr. Arevalo Lopez released, saying he had been held too long for a minor.

Judge Sweet said even though Mr. Arevalo Lopez had long since turned 18, he was still to be protected as an unaccompanied minor because he was three months shy of that age when he was caught.

"A birthday shall not result in detention," he ruled.

Oscar Canales Molina, 17, was also ordered released by a federal judge, in late 2017, according to news reports.

He entered the U.S. by sneaking across the border in July 2016.

Nobeli Montes Zuniga, 20, sneaked across the border three months earlier.

The immigration courts are so backed up that Mr. Montes Zuniga's next deportation hearing, like Mr. Arevalo Lopez's, isn't until 2021. Mr. Canales Molina doesn't even have a hearing set.

All three are now charged with assault with intent to cause physical harm, and ICE has placed detainer requests on them, meaning they are slated to be deported once they serve any sentences.

Without those criminal charges, Ms. Waldman said, unaccompanied alien children stand almost no danger of being deported, despite their illegal status.

Of the 31,754 unaccompanied minors apprehended from El Salvador, Guatemala and Honduras in fiscal year 2017 - when Mr. Arevalo Lopez was caught - some 98 percent are still in the U.S.