NEW YORK (AP) — A 17-year-old from El Salvador held in custody for seven months after he was accused of MS-13 gang activity during a secretive federal sweep has been released after a lawsuit was filed on his behalf.

The teen, identified as LVM in the court documents, came to the U.S. with his mother after he was targeted by gangs in his native country, the lawsuit said. He had no criminal history and no disciplinary problems in El Salvador, but was suspended from Bellport High School on Long Island in April after he was alleged to have flashed "gang signs" in the hallway.

Federal agents later said he was in MS-13, in part because of the school suspension, and because they claimed he had tattoos and wore gang clothing, the lawsuit said. But he disputed the allegations — for example, he has no tattoos, according to the lawsuit — and an immigration judge found he was not dangerous.

Many teenagers on Long Island have been held on gang accusations, swept up in various federal investigations into MS-13 activity there after an explosion of violence. In a visit to Long Island last July, Republican President Donald Trump promised his administration would "dismantle, decimate and eradicate" MS-13.

But federal and state authorities have declined repeated requests for even basic information in the sweep, made public in most law enforcement operations, such as the names of those arrested and the crimes they are accused of committing.

LVM was arrested by immigration agents in July 2017 as part of "Operation Matador" a large-scale gang sweep on Long Island, the lawsuit said. He was sent to a facility in Virginia and later one in Dobbs Ferry, New York, run by the Office of Refugee Resettlement, which handles children. At a custody hearing in December, a judge rejected the gang allegations, according to his attorneys.

But, according to the lawsuit filed by the New York Civil Liberties Union, he was detained "with no end in sight and no explanation for why he has yet to be returned to his mother's care."

LVM was released from custody on Feb. 22, less than a week after the lawsuit was filed. Civil liberties lawyers say the case, which seeks class-action status, will continue because as many as 40 others under the age of 18 are wrongly being held. They also suggested that LVM, like others in immigration-related lawsuits, was quickly released in an effort to undermine the legal effort.

"We're thrilled to see LVM reunited with his mom," said attorney Paige Austin. "Their family is so happy to be together again, after over half a year of waiting for a response to his mother's request for his release."

The lawsuit argued the government was violating a 2008 statute that required unaccompanied minors to be placed in the least restrictive setting appropriate, and should be released as soon as possible. But a policy from last summer requires the director of the resettlement agency to approve every juvenile's release. Lawyers argued the director, Scott Lloyd, was delaying the process without explanation.

Besides alleged gang activity, the Office of Refugee Resettlement detains children for other reasons too, such as disruptive behavior and mental health issues, the lawsuit said.

"This class includes a bunch of kids who even by ORR's own accusations are not gang affiliated," Austin said. "But they disregard all of it, and they talk about it as if it's only a gang phenomenon."

The refugee resettlement agency didn't comment on the lawsuit.