Gov. Andrew Cuomo's signed the measure shortly before midnight, following up on a promise to put his name on the legislation as soon as he received it rather than wait the usual 10 days to sign it for it to become law.
The Republican-led state Senate voted to approve the bill 33-29. The Senate vote was viewed as a major gain in an effort to allow gay marriage nationally.
The vote comes the day after President Barack Obama encouraged lawmakers to support gay rights during a fundraiser with New York City's gay community.
Obama endorses civil unions but not gay marriage. The president has said his views on the issue are evolving and that decisions on marriage should be left to the states.
Same-sex couples can begin marrying begin 30 days after Cuomo signs the bill. The Associated Press contributed to this report.