Gov. Andrew Cuomo has signed a bill allowing undocumented immigrants to apply for driver’s licenses in New York, his office said Monday night.

The state Senate approved the bill moments after a statement indicating Cuomo would sign it was issued, 33-29. The Assembly approved the bill earlier this month.

Cuomo only hours earlier raised the possibility of a veto of the measure over concerns the bill would create a “database” of undocumented people living in New York who would be subject to a federal immigration enforcement action.

Cuomo administration counsel Alphonso David subsequently sent a letter to Solicitor General Barbara Underwood seeking a legal opinion on whether the state would have to turn over the information to the federal government.

Instead, a statement came from Underwood’s boss, Attorney General Letitia James, seen broadly as a Cuomo ally. James rebuffed any concerns, saying the bill has safeguards against exposure.

“The legislation is well crafted and contains ample protections for those who apply for driver’s licenses,” she said. “If this bill is enacted and challenged in court, we will vigorously defend it.”

Soon after, a statement in response came from David, saying that Underwood “has remained unresponsive on this critical issue. With that said, based on the Attorney General’s representation, the Governor will sign the bill.”

The bill’s passage is the culmination of more than a decade of political battles, first launched in 2007 by then-Gov. Eliot Spitzer’s proposal to rescind Gov. George Pataki’s order that driver’s licenses require Social Security numbers, made after the Sept. 11 attacks. The proposal create a political firestorm and Spitzer withdrew it.

“All this has come together — a culmination of months, years, advocating for this and educating people who have had difficulty with this law,” said Sen. Luis Sepulveda, the bill’s main sponsor.