CAMP PENDLETON, Calif. (AP) — Most of the Marines who were labeled as criminals in front of their colleagues at Camp Pendleton after a human smuggling probe won’t go to court, the Marine Corps announced Tuesday.

Six Marines have pleaded guilty to various charges in courts-martial but 13 will be dealt with administratively and allowed to leave the service, while only four still face criminal cases, according to a statement from the 1st Marine Division, which is based at the Southern California camp.

The announcement follows the ruling of a military judge earlier this year that it was illegal for the military to arrest and accuse the Marines in front of their peers.

The case stems from the U.S. Border Patrol arrest of two Marines in July in a car near the Mexico border. A federal complaint said three Mexican migrants who came into the country illegally were sitting in the back seat of the black BMW driven by one of the Marines.

The three migrants told authorities that they were from Mexico and had agreed to pay $8,000 to be smuggled into the United States, documents say.

About three weeks later, nearly two dozen Marines were pulled out of a battalion formation of 800 troops at Camp Pendleton and some were accused of being criminals in front of their unit. The unit’s leaders called them “a cancer” and “bad Marines,” defense attorneys said.

Sixteen Marines accused of human smuggling were handcuffed and marched away. Another eight Marines suspected of drug offenses were removed from the formation and some were taken to the brig.

The July 25 arrests were captured on video by the Marine Corps and published by the San Diego Union-Tribune in November.

In the end, only 10 of those in the formation were charged with various crimes, such as distributing LSD, stealing smoke grenades and transporting immigrants illegally to help a smuggling operation, according to charge sheets. Several other Marines were charged later.

Last month, a military judge, Marine Col. Stephen Keane, agreed with defense attorneys who said the command had violated the rights of some of the accused. Keane said the public display of the arrests amounted to unlawful command influence, when commanders use their positions of power to affect a case and compromise the ability to hold a fair trial.

That left prosecutors facing the prospect of having the cases dismissed.

“After that ruling, I think the government saw the writing on the wall and wanted to get this out of the court system,” Marine Capt. Charles Whitman, who represents a Marine charged with a drug crime, told the Union-Tribune Tuesday.

His client will be administratively processed out of the Marine Corps but his commanding officer will determine the Marine’s discharge status, Whitman said.

Whitman noted the recent war crimes trial of Navy SEAL Edward Gallagher, who was tried at Camp Pendleton and acquitted of most charges.

“The military justice system is under a lot of scrutiny,” Whitman said, “but it actually worked here — the judge got it right. It’s actually a positive for the Marine Corps in that it shows the system can be fair.”

U.S. Border Patrol officials say smuggling rings have been luring U.S. troops, police officers, Border Patrol agents and others to work for them as drivers — a crucial component of moving migrants further into the United States once smugglers get them over the border from Mexico.

The Marine Corps on Monday announced that a junior enlisted Marine with Headquarters Battalion of the 1st Marine Division was arrested by the Border Patrol on Monday at a San Diego border checkpoint for allegedly bringing in “undocumented immigrants.”

Military investigators were looking into the case.