ALBANY — Lawmakers voted late Friday to legalize same-sex marriage, making New York the largest state where gay and lesbian couples will be able to wed and giving the national gay-rights movement new momentum from the state where it was born.