A San Diego judge ruled Monday that the Trump administration was acting within the law in separating more than 900 children at the border based on their parents being deemed unfit or dangerous.

U.S. District Judge Dana Sabraw previously ruled the administration must locate and reunite children separated from their parents after the controversial "zero-tolerance" policy was first announced in the spring of 2018.

The American Civil Liberties Union had argued that the allegations against parents were dubious and based on minor offenses and asked Sabraw in July to rule on the legality of separating 911 children since he halted the practice in 2018.

TRUMP ADMINISTRATION ASKS SUPREME COURT TO ALLOW RULE RESTRICTING GREEN CARDS FOR IMMIGRANTS ON WELFARE

“It is an invitation that is potentially massive in scope, invades an area that is particularly within the province of the executive branch to secure the nation’s border, and goes beyond this court’s class certification and preliminary injunction orders, which were focused on the administration’s practice of separating families at the border for the purpose of deterring immigration, and failing to reunify those families,” Sabraw wrote in a 26-page decision.

He said he didn’t find any evidence the administration was abusing its power.

Under zero-tolerance, the administration began prosecuting all those suspected of crossing the border illegally, resulting in children being separated from their detained parents.

However, Sabraw said a 90-minute DNA test must be used when there is doubt the adult is the child’s parent.

ACLU attorney Lee Gelernt said in a statement after the ruling, “The court strongly reaffirmed that the Trump administration bears the burden if it attempts to separate families based on an accusation that the adult is not the child’s parent. We are evaluating the decision to determine next steps on how to ensure that children are not separated from their parents based on minor infractions.”

CLICK HERE TO GET THE FOX NEWS APP

The Justice Department has not yet commented on the ruling.

The Associated Press contributed to this report.