Hours after the Democratic-controlled Assembly approved a bill allowing undocumented immigrants to apply for driver’s licenses in New York, the campaign arm of the Assembly Republicans began a Facebook ad blasting the measure.

“Even though New Yorkers are overwhelmingly opposed, Assembly Democrats have voted to legalize illegal immigrants getting New York State Driver’s Licenses,” the ad says. “This is an endorsement of the lawlessness on our country’s southern border and a backdoor to legal status.”

The bill’s passage remains in doubt in the state Senate, also controlled by Democrats.

But the social media ad is another reminder of the fraught politics surrounding the proposal, first made and later withdrawn in 2007 by then-Gov. Eliot Spitzer — and perhaps a sign of things to come in next year’s legislative elections.

Even now, some Democrats running in off-year local elections in the suburbs have quietly grumbled about the bill’s effect on their campaigns.

The bill’s proponents this year argued the measure made sense on economic terms: Undocumented people living in New York need licenses to get to work and would have access to car insurance if they had a license to drive a car, boosting traffic safety in the process.

The measure gained the endorsement of the Business Council on these grounds.

Still, a Siena College poll this week found a majority of voters opposed to the bill in New York statewide, and Long Island and upstate Democrats have expressed reservations with the bill in the Senate.

Several upstate Democrats in the Assembly voted against the legislation on Wednesday, with at least 10 skipping the vote entirely.