It was a day of both drama and a bit of whiplash as the state Senate put the finishing touches on a bill that allows undocumented immigrants to apply for and receive driver’s licenses.

Gov. Andrew Cuomo signed the measure quickly into law, but not before raising the possibility of a veto out of concern, he said, over federal immigration officers using the DMV’s list of those receiving the standard license as a “database” for enforcement actions.

Cuomo wanted a legal opinion from the solicitor general, Barbara Underwood, as to whether the state would have to turn over the information to the federal government.

Instead, Cuomo got a statement from his politically ally and Underwood’s boss, Attorney General Letitia James, who called the law constitutional and contained “ample safeguards” for those who wish to apply for a license.

Cuomo’s top counsel in a tersely worded statement said the governor would sign the bill.

All this fell against the backdrop of a contentious vote in the Senate, with the bill narrowly passing 33-29 and seven Democrats voting agains the bill. The Democratic “no” votes — coming from Long Island and the Hudson Valley, represent districts that were once held by Republicans.

The state Democratic Committee Chairman Jay Jacobs had warned several Democrats about the political fallout of the bill; he says he was acting independently of Cuomo in issuing his warnings.

Cuomo’s 11th-hour concern seemed to be an attempt to thread a needle over an unpopular proposal that nevertheless had the votes to pass in the Legislature. Instead, it got caught in the new political fabric in Albany.

Was it cover for the potentially vulnerable Democrats who voted against the bill? After all, Sen. Kevin Thomas, a freshman who flipped a Republic-held seat last year also cited the governor’s concern: ICE could use the information to aid deportations.

The bill also highlighted the country and state’s stark divide on immigration policy and the undocumented immigrants themselves. Business groups lined up with immigration advocacy organizations, touting the policy as an economic issue and a traffic safety issue.

The driver’s licenses that would be issued will not let a person enter a federal building or go on a plane by this time next year, they argue.

But on the other side is a majority of voters statewide and Republican lawmakers who point this being an issue of fairness and security. Then-Gov. George Pataki’s decision to require Social Security numbers for driver’s licenses following the Sept. 11 attacks still resonated.

And then there’s the third camp of lawmakers in recent weeks, frustrated New York, or any state for that matter, has to act on immigration policy after decades of federal government inaction.