WASHINGTON — The struggle for African-Americans’ rights, symbolized by the bloody 1965 Selma march, is as old as the nation. The effort for American women’s rights began at Seneca Falls, N.Y., more than 150 years ago.

The modern fight for gay rights is, by contrast, less than a half-century old, dating from the 1969 Stonewall uprising in New York. But this week, as the Supreme Court hears two landmark cases on same-sex marriage, the speed and scope of the movement are astonishing supporters.

“We, the people, declare today that the most evident of truths — that all of us are created equal — is the star that guides us still, just as it guided our forebears through Seneca Falls, and Selma, and Stonewall,” President Obama said in his Inaugural Address in January, in a moment of history for gay men and lesbians, who were included in such a speech for the first time. “Our journey is not complete until our gay brothers and sisters are treated like anyone else under the law.”

The changes have been so swift that it is sometimes surprising to remember how many gay men and lesbians were until recently in the closet and how many hurdles there have been along the way. “We were all hiding,” said former Representative Barney Frank, Democrat of Massachusetts, who in 1987 became the first member of Congress to voluntarily disclose his homosexuality. At the time, the public disapproval of homosexuality — so powerful that gay men and lesbians hesitated to identify themselves, much less seek political change — helped stunt the movement’s emergence.