Even 40 years on, police officer Seymour Pine is still amazed. "We knew something had happened that had never happened before. We'd never had any trouble, but it just came out of nowhere," he said.

"It" was the Stonewall riot in the early hours of 28 June, 1969, in New York's Greenwich Village, when, sick of being harassed, the gay community fought back en masse for the first time and the grassroots gay and lesbian equality movement was born.

Deputy Inspector Pine led the raid on the Stonewall Inn that night, when his handful of club-wielding officers suddenly came under siege from an angry mob of gay men and women.

"It was never the same again," the 89-year-old retired policeman said from New Jersey last week, admitting that the police were anti-gay, but just "doing our jobs" when the raid turned into a riot.

Now he's witnessing another gay revolution across the US - less violent, but no less significant, and one he is comfortable with. "It's another turning point. The country has come a long way," he said.

The most visible sign is the flurry of states legalising same-sex marriage. As Massachusetts celebrated five years of gay marriage this year, Connecticut, Vermont, Maine and Iowa came on board. New Hampshire is on the verge, as is New York, and although the gay marriage ban is likely to be upheld in court in California this week, even former opponents say it can't last.

But it is not just marriage. There are two openly lesbian women on the reported short list to fill the forthcoming vacancy on the supreme court. President Obama has appointed more than 30 gay men and lesbians to senior posts within his administration.

Comedian Wanda Sykes, African American and a lesbian, was the guest speaker at the high-profile White House Correspondents Dinner in front of Barack and Michelle Obama earlier this month. And in popular culture, gay singer Adam Lambert came a close second in the American Idol contest last week, in which 100 million viewers voted - only months after former Idol star Clay Aiken came out of the closet. Ellen DeGeneres has not only revived her TV career since her sitcom was cancelled in 1998 after she came out, but she has become a "face of CoverGirl" make-up model. Hollywood's Jodie Foster and Kelly McGillis recently came out after years in the closet, though male stars are noticeably more reluctant.

Meanwhile, cable TV channel MSNBC's Rachel Maddow, 36, is a success with her eponymous politics show and a leading voice urging Obama to honour his promise to repeal the ban on openly gay personnel in the military.

She hailed not a single tipping point, but "a day-to-day struggle" resulting in enormous progress over the past four decades, based on "more and more people coming out". She has been out since she was 17.

"There has never been a better time to be gay in America than now," said Daniel O'Donnell, one of four openly gay members of the New York state assembly and brother of TV star, gay-cruise company owner and lesbian campaigner Rosie O'Donnell. "There has been a change just in the past couple of years. We've never been as close to equality as citizens in my lifetime."

O'Donnell believes the New York state senate will overcome its past resistance and pass the assembly's hard-fought gay marriage bill next month, to be followed soon after by New Jersey. "It makes it more difficult as it spreads from New England for Pennsylvania, Maryland, etc, to resist the momentum. Five years of gay marriage in Massachusetts and the sky did not fall," he noted.

No one expects the likes of Alabama, Mississippi or Texas to allow gay marriage any time soon - and many gay people spurn the institution of marriage as too conventional anyway - but there is a growing view that, long term, the tide has turned.

Obama has a personal, religious sticking point on gay marriage and defers to individual states to make their own decisions. He is a paradox at times, with his attempts to reach across any aisle, no matter how wide, inviting anti-gay evangelical minister Rick Warren to lead prayer at his inauguration and gay bishop Gene Robinson to pray at pre-inauguration celebrations.

But he is still seen as the most gay-friendly president in history, with the caveat that the gay community is waiting for him to live up to his promises on repealing the Defence of Marriage Act, which denies the recognition of same-sex marriage at the federal level, and the flawed "Don't Ask, Don't Tell" military restrictions, which forbid officers from inquiring about their personnel's sexual orientation, but prohibit servicemen and women from being openly gay.

Obama was the first president to mention gay rights in his election victory speech and gay men and lesbians are excited - though increasingly impatient - about the prospects for equality.

"It is truly an honour to be here," Wanda Sykes said when she stood up at the prestigious correspondents' dinner for the first black president. Her address ranged from the hilarious to the edgy, leading to days of controversy, but sparked by the tasteless digs she made at right-wing pundit Rush Limbaugh, not the fact that she is a lesbian or black.

"Wanda, Ellen, Rachel - openly gay people in visible places and positions of power - it's so cool. There have been spectacular changes," said fashion writer Robert Bryan, 63. He was a banker, deeply in the closet, when he stumbled on a rumpus outside the Stonewall Inn 40 years ago. At first, drag queens were can-can kicking and singing taunting songs at the outnumbered police, but it escalated as beatings began to accompany arrests, and Bryan joined in. "It was fun and exciting. But then people got more and more angry at the police violence, we had just had enough of being marginalised," he recalled last week. There was rioting for five nights.

The 40th anniversary will be celebrated at gay pride parades across the world this summer. The BBC is planning a major radio documentary about Stonewall and the New York public library will open a prominent exhibition called 1969: The Year of Gay Liberation.

"Equality? It's all over bar the shouting. We will prevail," said author Rita Mae Brown, who witnessed the Stonewall riots. She was then a major figure in the feminist movement and became an icon with her 1973 watershed lesbian novel Rubyfruit Jungle

Victory for Brown now would be for a person's sexuality to be seen as irrelevant. "I don't want to talk about being gay. I want to talk about what's happening in Afghanistan, the environment, the economy... I hope people celebrate this summer and remember how far we have come, then get outside themselves to engage with other great problems in society," she said.

This spring, Obama specifically sent out invitations to gay parents to attend the annual Easter egg roll on the White House lawn. Trite, perhaps, but revealing. And Stanford law professors Kathleen Sullivan and Pamela Karlan, both openly gay, may not be regarded as frontrunners to fill the gap in the supreme court when Obama announces his nominee, but their very mention is an epiphany.

Gay congressman Barney Frank, often voted brainiest and wittiest politician in Congress, is currently orchestrating federal anti-discrimination legislation to protect gay people in the work place.

New York state Republican assemblywoman Janet Duprey voted No on the gay marriage bill when it failed to become law in 2007, but voted Yes earlier this month and now hopes it will pass in the state senate. She said she was persuaded by the presence of a lesbian couple living three doors down on her block, and the opinions of "lovely, reasonable" gay constituents - "doctors, teachers, government workers, all sorts of decent citizens" - who lobbied her.

Duprey is now receiving cards warning her that she will burn in hell, but she said coming into contact with ordinary gay people who "just wanted equal rights" swayed her. Civil union partnerships have too many legal weaknesses, she said. "Everyone needs a lesbian couple on their block."

Meanwhile, Rachel Maddow is lobbying for Obama immediately to issue a moratorium on troops being discharged from the military for being openly gay, including a soldier who came out on her show.

Other campaigners are prepared to give Obama the benefit of the doubt for now, while he fixes the economy and deals with two wars.

This summer is also the 40th anniversary of the Woodstock music festival. As both gays and straights gear up for a new summer of love, author David Carter, who wrote Stonewall, the definitive book on the riots and their significance, put the onus on Obama not to betray the spirit of optimism. "If he lives up to his promises, then it could be a golden age for our rights," he said.

Landmarks on the way

1970 Gay Liberation Front organises parade to mark first anniversary of Stonewall riots in New York. It sparked similar parades in other cities and countries and became an annual celebration later dubbed "gay pride".

1973 American Psychiatric Association removes homosexuality from list of mental disorders. It took 33 more years for the Pentagon to follow suit.

1981 First cases of acquired immune deficiency syndrome (Aids) are identified among gay men in the US. By 2009, there have been at least 25 million deaths worldwide and half a million in the US.

1993 Don't Ask, Don't Tell policy allowed gays and lesbians to serve in the US military - but not openly.

2003 Supreme Court ruling decriminalises homosexuality across the US. Massachusetts becomes first state to legalise gay marriage.