Mr. Castorina said in an interview that he and Ms. Malliotakis would ask the appellate court for a longer stay to prevent the destruction of the documents.

“We always knew we would be in for the long haul on this issue,” he said.

The lawsuit covers only the first two years of the program, because the documents were supposed to be purged by Dec. 31, 2016. As of Dec. 7, under a City Council law, the copies of information for any new applications were immediately destroyed.

“It’s my opinion that these ID cards are being administered in a very scant vetting process,” Mr. Castorina said. “They put us all at risk and, as a result, the destruction of any type of government records, particularly those that are used to procure government-level identification, are a great cause of concern and make us all a lot less safe.”

The suit was initiated with President Trump’s crackdown on immigration clearly in mind. Advocates for immigrants feared that keeping copies of the underlying documents on file could lead the authorities to applicants, putting them at risk of deportation.

But Justice Minardo dismissed politics — on both sides — in his ruling on Friday.

“Much ado was made about the recent federal election of a Republican President with an immigration agenda and petitioners’ support of that president and the very public opposition of certain respondents,” he wrote in his decision. “Notwithstanding these positions, this court cannot make new law based upon a political party’s agenda.”