A legal challenge to the new state law that will allow undocumented immigrants living in New York to apply for and receive driver’s licenses was rejected on Friday by a federal judge.

The lawsuit had been filed by Democratic Erie County Clerk Mickey Kearns, who is among the local government officials who have pledged to not enforce the law, approved in June by state lawmakers and Gov. Andrew Cuomo. The measure is set to take effect before the end of the year.

“The law aims to make our roads safer and our economy stronger,” said Attorney General Letitia James. “We will continue to defend it.”

Supporters of the measure celebrated the ruling on Friday even as other lawsuits loom.

“Green Light is a well crafted bill that will make roads safer for all New Yorkers,” said Assemblyman Marcos Crespo, the Bronx Democrat who sponsored the bill in his chamber.

Other legal challenges to the measure remain, including one filed by Rensselaer County Clerk Frank Merola. County clerks who administer local motor vehicle offices for the state had led the previous opposition to the proposal by then-Gov. Eliot Spitzer in 2007.