[What you need to know to start the day: Get New York Today in your inbox.]

As he watched a live stream of a New York State Senate vote on Monday night, Michael P. Kearns, the county clerk in Erie County, sat in disbelief. For nearly two decades, efforts to allow undocumented immigrants to get driver’s licenses had failed. What he was seeing felt impossible: The State Legislature was passing the bill.

“I was shocked,” said Mr. Kearns, who immediately took to Twitter to voice his dissent. “I knew I’d have to take stand against this.”

With that vote, New York became the 13th state to grant driver’s licenses to undocumented immigrants, an issue that has been entangled in a politically divisive, decades-long debate in the state.

But the win for Democratic lawmakers and immigration advocates is already being challenged. A growing coalition of county clerks say they will refuse to issue licenses, and they are threatening to take their fight to court.