Ms. Gillibrand, who had represented a conservative upstate district in Congress, was not well known to liberals or gay rights groups at the time. But in an interview, she said she had realized from an early age that discrimination against gays was wrong.

Her mother — a black belt in karate who the senator said “did things differently her whole life” — worked in the arts and surrounded herself with gay friends. During the height of the AIDS crisis, Ms. Gillibrand’s sister, a playwright and actress, volunteered to help children with AIDS.

And when Ms. Gillibrand was a young associate, working long nights at the law firm Davis Polk & Wardwell, she recalled, “the straight men found time to date and get married and have kids and went home at six every night, and the only ones left were the women and gay men.”

So she wound up vacationing with gay colleagues on Fire Island and in the Hamptons, and forging lifelong friendships. “A lot of them are now having children,” she said. “And it never occurred to me that they should not have every benefit that I have.”

Richard Socarides, a former aide to President Bill Clinton and founder of Equality Matters, a gay advocacy organization, said he was initially wary of Ms. Gillibrand, thinking she was courting gays for purely political reasons as she sought to broaden her appeal statewide.

But she won him over with her fervor, strategic thinking, fearlessness and litigator’s tenacity. “If she has decided she’s going to get something done,” he said, “don’t get in her way, because you will get run over.”