Gov. Andrew Cuomo on Monday night signed legislation granting driver’s licenses to illegal immigrants — shortly after the controversial measure passed the state Senate.

Cuomo’s action came despite throwing supporters a last-minute curveball by asking the state’s top civil attorney, Solicitor General Barbara Underwood, to review the measure for possible safety concerns — threatening to veto it if he didn’t like her assessment.

FILE: New York Gov. Andrew Cuomo speaks at the Lesbian, Gay, Bisexual & Transgender Community Center.

FILE: New York Gov. Andrew Cuomo speaks at the Lesbian, Gay, Bisexual & Transgender Community Center. (AP)

“You could create a database for the feds to use to actually track down undocumented people,” Cuomo said on WAMC radio. “California passed a law, and they are now in litigation.”

But Underwood’s boss, Attorney General Tish James, later released a statement amid the Monday-night vote arguing that the bill is legally sound.

PATAKI CALLS ON CUOMO TO INTERVENE IN PAROLE BOARD’S DECISION TO RELEASE 16-YEAR-OLD GIRL’S CONVICTED KILLER

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

The law takes 180 days to go into effect, meaning the first licenses will be available in December.

GET THE FOX NEWS APP

The measure on Monday passed the state Senate by a 33-29 count, often eliciting emotional remarks from both sides of the aisle during the floor vote.

To read more from The New York Post, click here