A Staten Island judge has rejected a lawsuit by two GOP lawmakers trying to stop Mayor Bill de Blasio from destroying records related to his municipal ID program that issues cards regardless of whether the cardholder is living legally in the country.

State Supreme Court Justice Philip Minardo ruled in early April that Assemblymembers Ron Castorina Jr. and Nicole Malliotakis have no legal right to stop de Blasio from deleting scanned copies of documents, such as foreign passports, submitted by applicants to establish residency and identity.

The destruction is on hold until at least April 17, and Castorina said in an interview he would appeal.

A provision of the law establishing the ID card program contained a provision allowing deletion that one backer of the program said was inserted “in case a Tea Party Republican comes into office.”

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

In the lawsuit, filed late last year, Castorina and Malliotakis argued unsuccessfully that de Blasio’s plan endangers national security by facilitating identity theft and empowering terrorists who might use the card to open bank accounts.

In a series of hearings Minardo convened, the NYPD’s top counterterrorism official took the witness stand to reject those fears. He said, “I hope every terrorist opens a bank account.”

advertisement | advertise on newsday

Amalgamated Bank, which says it has opened more bank accounts based on IDNYC cards than any other city bank, hailed the decision.

“This decision is a clear rebuttal of false claims made by opponents of the municipal ID program,” the bank said.

Anyone can sign up for the card, which includes free museum admissions and other benefits. The program was intended to help bring New Yorkers out of the shadows who need ID to pick up children from school, interact with the police and perform other errands of everyday life.

The city still plans to keep a database of name, address, signature and photo.