On New Year's Day 1965, hundreds of gay San Franciscans arrived at 625 Polk Street in the city's Tenderloin district for a much-anticipated "Mardi Gras Ball."

The event organized by gay rights -- or, to use the then-common term, homophile -- activists was not unlike the thousands of public parties being held this June during Lesbian, Gay, Bisexual and Transgender Pride Month: There were drinks and music, hand-holding, flirtatious glances and kisses between friends old and new. But it was also a private affair -- $5 tickets had to be bought ahead of time -- in a city where gay people regularly faced threats and arrests for gathering together and showing affection.

Perhaps the most striking aspect of the San Francisco ball, however, was its purpose beyond merriment: It was held as a fundraiser for pro-gay clergy.

Today, although Americans for and against gay rights cite their religious beliefs, those who oppose same-sex marriage and other civil rights for LGBT individuals have been especially vocal in declaring that God is on their side. That's not always been the expectation about the faithful. In the mid-1960s, LGBT activists often looked to men of the cloth as allies in their fight for justice and human rights, according to historians.

Just months before the ball, about two dozen Bay Area Methodist, Lutheran, Episcopal and United Church of Christ clergy and gay activists had formed the Council on Religion and the Homosexual to promote the "need for a better understanding of human sexuality" and its "broad variations and manifestations."

On Dec. 7, 1964, a front-page article in the San Francisco Chronicle announced the launch of the Council on Religion and the Homosexual.

Clergy and lawyers for the group had negotiated with police -- who had a habit of shutting down LGBT events -- to let the dance go forward. But according to contemporary newspaper articles, police still showed up that night, taking pictures of those entering as an intimidation tactic. When the cops demanded to get inside, the lawyers reportedly blocked them. Six people ended up in jail for interfering with the police and disorderly conduct.

The clergy fought back with a press conference the next day. "Angry Ministers Rip Police," said a front-page headline in the San Francisco Chronicle below a picture of men in clerical collars. The clash mobilized both the city's gay community and the pastors. The American Civil Liberties Union brought a lawsuit over the arrests -- the first time the ACLU had joined a legal battle over gay rights, according to the LGBT Religious Archives Network.

"That was years before the 1969 Stonewall riots, which is popularly considered the beginning of the gay rights movement," said Heather White, a visiting assistant professor of religion at the New College of Florida who has spent years combing through LGBT archives for an upcoming book, tentatively titled Reforming Sodom: Protestants and the Rise of Gay Rights. "And that's just one of the best-known stories. There were Councils on Religion and Homosexuality and similar groups in D.C., Pennsylvania, Ottawa, Hawaii."

White is among a growing group of scholars who have been working to uncover the broad -- and for many, surprising -- history of religious gay rights activism. The LGBT Religious Archives Network has documented hundreds of stories like that of the San Francisco clergy since it was founded 13 years ago at the United Church of Christ-affiliated Chicago Theological Seminary. The organization is now based in Berkeley, California, at the Pacific School of Religion's Center for Lesbian and Gay Studies in Religion and Ministry.

A mid-1970s fact sheet and flyer for New York's Congregation Beit Simchat Torah.

The network's website offers a series of profiles of and oral history interviews with Protestant, Catholic, Muslim, Jewish, Buddhist and Pagan LGBT clergy and religious activists, living and dead. Online exhibits cover topics ranging from the Council on Religion and the Homosexual to the 1973 UpStairs Lounge fire in New Orleans, an anti-gay arson incident that killed 32 people, including many members of the city's gay-friendly Metropolitan Community Church, to New York's Congregation Beit Simchat Torah, which launched in 1973 and calls itself the world's largest gay synagogue. The network also holds archives on the lives of people like William R. Johnson, who in 1972, as a member of the Golden Gate Association of the United Church of Christ, became the first gay American Protestant to be ordained.

White, who sits on the network's advisory committee, said expectations about how religion would view gay rights began to change after the 1960s.

"What we know of the face of religion and gay rights has been shaped by a shift that occurred in the 1970s with the rise of conservative Christianity. It's a consolidated political force that wasn't in place before then. There were certainly conservative people and religious people who were involved in politics, but in the 1950s and 1960s, homophile organizations saw religious leaders as likely allies," said White. "That is less of the case today, though things are changing."

A Pew Research Center survey, released Thursday, found that 62 percent of Americans now say homosexuality should be accepted, rather than discouraged, by society. But clear lines still divide religious Americans when it comes to gay rights, especially same-sex marriage. Polls show that white evangelicals tend to strongly oppose gay marriage. The nation's largest churches -- including the Roman Catholic Church, the Southern Baptist Convention, the United Methodist Church and the Church of Jesus Christ of Latter-day Saints -- officially do not support same-sex marriage.

On the other hand, Catholic Americans as individuals tend to be supportive of gay marriage. And several denominations -- including the Presbyterian Church (USA), the Episcopal Church, the United Church of Christ, the Unitarian Universalist Association of Congregations, and both Reform and Conservative Jews -- allow clergy to perform same-sex marriages or blessings.

The first issue of Affirmation, a newsletter for gay and lesbian Mormons, was printed in 1980.

"Some of the biggest gay rights activists and organizations started their work in churches," said Bernard Schlager, executive director of the Center for Lesbian and Gay Studies in Religion and Ministry and an associate professor of cultural and historical studies as the Pacific School of Religion.

He pointed to the Metropolitan Community Church, which gay rights activist Troy Perry launched in Los Angeles in 1968 to cater to gay people. The relatively small church has 222 congregations worldwide today, but Schlager said its influence was "monumental" in pro-LGBT Protestant movements. Another noted gay rights group, PFLAG -- formerly known as Parents, Friends and Family of Lesbians and Gays -- had its first meeting in 1973 at the Metropolitan-Duane Methodist Church in New York City's Greenwich Village (now called the Church of the Village).

Schlager suggested that the widespread, if inaccurate, perception of religion firmly opposing gay rights is also shifting. "It's come to the point that sometimes people today say it's more difficult to come out as a person of faith than it is to come out as LGBT in religious circles," he said.

Melissa Wilcox, an associate professor of religion and gender studies at Whitman College in Walla Walla, Washington, shared a similar view.

"With the increasing visibility of the marriage rights movement, we have started to see LGBT-supportive groups [within religious communities] being able to get their message out more clearly. That's a battle for them, but many have been there all along," said Wilcox, who also sits on the LGBT Religious Archives Network's advisory committee.

After decades of church activism, for example, the Presbyterian Church (USA) General Assembly last week voted to allow its pastors to officiate gay marriages in states where they are legal. The church's presbyteries, or regional bodies, are also scheduled to vote on whether to change the definition of marriage to cover "two people," rather than only a man and a woman.