ALBANY – New York will become the 13th state to allow undocumented immigrants to apply for driver's licenses after the state Senate approved the measure and Gov. Andrew Cuomo signed it into law Monday night.

Immigrants without legal status will soon be able to use foreign documents such as passports to verify their identification when they apply for driving privileges in New York under the bill, which the Senate approved 33-29.

The vote ended months of uncertainty at the state Capitol, where Democratic lawmakers in marginal districts struggled with the controversial bill as legislative leaders weighed whether it had enough support to pass.

And it capped a whirlwind day in Albany that began with Cuomo — who had previously pledged his support for the bill — publicly suggesting he may veto it.

But Cuomo, who said he was concerned federal immigration officials could easily obtain DMV records, signed the bill hours later after Attorney General Letitia James said it provides "ample protections" for applicants.

"With that said, based on the Attorney General's representation, the Governor will sign the bill," Counsel to the Governor Alphonso David said in a statement.

The bill will take effect in 180 days.

Senate leader praises bill

Senate Majority Leader Andrea Stewart-Cousins, D-Yonkers, called the bill the "right step forward for New York state."

Democrats cast all 33 votes in favor. Seven Democrats — including six from Long Island and Sen. James Skoufis, D-Woodbury — voted against it, as did all 22 Republicans.

"By passing this needed legislation, we are growing our economy while at the same time making our roads safer," Stewart-Cousins said in a statement.

The vote came less than a week after the Assembly approved the bill and six months after Democrats took control of the Senate, which Republicans had led since 2011.

Those undocumented immigrants who pass a driving test would receive a license with a stamp ensuring it can't be used for federal purposes.

Immigrant organizations and other supporters praised Senate Democrats for approving the measure while Republicans condemned them, vowing to use the issue against them at the polls next year.

Advocates have long said the bill, a version of which has been around Albany since at least 2007, would allow undocumented immigrants in rural areas to obtain the ability to drive legally. It would also allow them to get insurance and avoid the threat of deportation if they are pulled over.

Veto threat worries advocates

But Cuomo's comments early Monday had left them fearful of a veto, which would be a major blow to those who spent six months marshaling support for the bill that had remained stalled in Albany since then-Gov. Eliot Spitzer made an unsuccessful push for it in 2007.

"Nobody wants to create a database that the feds can then use to pursue undocumented people for their political purposes," Cuomo told reporters in Manhattan.

"And I have no doubt this president, as soon as we pass this law, he will be very interested in using the database and I would not be shocked if he didn’t want to make the issue a political issue here in New York."

Steve Choi, executive director of the New York Immigration Coalition, called Cuomo's remarks "misinformed."

The bill was amended earlier this month to require ICE or U.S. Customs & Border Protection to obtain a judicial warrant before obtaining any state DMV data related to driver's licenses.

"I think the protections that we have built in here are ironclad, and we will stand on them any day of the week," Choi said.

In a letter to Solicitor General Barbara Underwood, David asked her to assess the bill and suggest changes "as soon as possible."

The Legislature's annual session at the Capitol is scheduled to end Wednesday.

In response, James — Underwood's boss — made public a legal memo from her office that broadly assessed the law, determining it "constitutionally and legally sound."

“I support the Green Light bill, and the Office of Attorney General has concluded that it is constitutional," she said. "We will not opine on any actions the federal government may or may not take."

David said Cuomo would trust James' determination.

"We hope the Attorney General's assessment is correct for the safety of the thousands of undocumented individuals who are relying on her legal opinion," he said.

Debating the issue

Critics of the bill said driving is a privilege and should be reserved for those in the country legally. County clerks, who said they are ill-equipped to determine whether foreign documents are valid, are among those who criticized the measure.

"People who are here in violation of our laws shouldn't get a free pass," said Sen. Rich Funke, R-Perinton, Monroe County. "Illegal is illegal."

During the debate Monday, Senate Republicans questioned whether the bill would lead to voter fraud, noting driver's license applicants can register to vote while filling out DMV paperwork.

Democrats pushed back, saying it would remain illegal for a non-citizen to register to vote.

If driver's license applicants are also registering to vote, they have to sign an affidavit certifying they are a citizen. If they lie, they face a penalty of up to $5,000 and up to four years in jail.

Monroe County Executive Cheryl Dinolfo said the bill is "troubling." She traveled to Albany on Monday along with her Democratic challenger Adam Bello, the county clerk, to urge senators to vote against the measure.

"It is patently unfair to reward folks who are here without legal presence," she said.

Cuomo explains his concerns

Supporters of the bill had long questioned Cuomo's commitment to the measure, despite Cuomo repeatedly signaling his support for it.

Earlier this month, state Democratic Committee Chairman Jay Jacobs — whom Cuomo appointed to the role — urged Democratic senators to avoid putting the bill to a vote, arguing that it would be politically detrimental to suburban senators in marginal districts.

Choi said the state's immigrants should be able to decide for themselves whether obtaining a driver's license is worth the risk.

An undocumented immigrant is much more likely to be picked up by ICE if he is driving around unlicensed, Choi said.

"The idea that we are going to protect immigrants from being deported by denying them a license, that is simply hogwash," he said.

Republicans promise political pushback

Republicans have made clear they are planning to use the issue against Democrats at the polls next year, when all 213 state lawmakers are up for re-election.

Assembly Republicans published Facebook advertisements last week criticizing Democrats for passing the measure.

The ad showed a New York driver's license issued to the name "UNDOCUMENTED IMMIGRANT." The ID photo showed a faceless, shadowy figure in a hooded sweatshirt.

Senate Minority Leader John Flanagan, R-Suffolk County, has pledged to use the issue in the GOP's bid to take back the Senate.

Democrats won control of the chamber last year for the first time since 2008.

"In an effort to satisfy their radical base, Democrats are focused on all of the wrong things for New York," Flanagan said in a statement Monday.

JCAMPBELL1@gannett.com

More:Immigrant siblings discuss why they want a New York driver's license

More:New York Assembly green lights driver's licenses for undocumented immigrants

More:Legalizing marijuana, driver's licenses for undocumented immigrants: See where New Yorkers stand