Two Republican Assembly members are suing to stop Mayor Bill de Blasio from a Trump-inspired purge of records on people who signed up for municipal ID cards that are offered regardless of immigration status.

A state judge late last month temporarily barred the city from destroying the records while the court considers the suit, which challenges a provision of the 2014 law establishing the IDNYC cards that empower de Blasio to delete the database.

“What the mayor is doing here is essentially making himself the savior of undocumented people, and it’s just ridiculous,” said Assemb. Ron Castorina Jr., who appeared Tuesday at City Hall with his co-plaintiff, Assemb. Nicole Malliotakis.

Both Staten Island lawmakers oppose any form of the identification program because they think the government should not issue ID cards to anyone in the country illegally.

Soon after Donald Trump was elected, de Blasio promised to resist many of Trump’s campaign promises, including a vow to round up people living illegally in the United States.

More than 900,000 people have signed up for the cards. By offering benefits like free admission to museums, the city encourages all New Yorkers to apply to avoid making the cards a scarlet letter on immigration status.

De Blasio’s spokeswoman Rosemary Boeglin said, “We’re absolutely confident that the law is on our side and that guarding these records is the right move to protect New Yorkers’ privacy and keep our communities safe.”

The suit, filed last month, claims that the city officials are exceeding their legal authority and violating state open-records laws.

Ravi Batra, a lawyer working pro bono on the challenge, said that destroying records could allow a terrorist to get a government-issued card through fraudulent means, with no ability to audit the program.

Though he knows of no cases of fraud with IDNYC, he said: “We don’t know, but the fact that there’s a gaping hole that a Mack truck could go through is enough to frighten you.”

Boeglin said the program employs “very stringent security standards” developed with the NYPD. The ID may not be used to rent a vehicle or board a plane, she said.

Separately Tuesday, the city announced the program would continue to be free and the city would no longer retain applicants’ proof-of-identity documents.