(CNN) -- In a historic turnaround, the ballot box is showing America's shifting attitudes about same-sex marriage. After gay marriage rights died at the polls dozens of times in the past, on Tuesday they passed in at least two states.
Rarely do popular votes reflect such dramatic social changes.
The result: Maryland and Maine will now allow couples like Chyrino Patane and James Trinidad to tie the knot.
The Maryland couple has been together for seven years, and now, after the historic vote, they plan to marry in the next six months to a year.
"Both families will be at the wedding," Patane said.
But the win was hard fought and the margin of victory was small.
"We've lost at the ballot box 32 times," said Paul Guequierre of Human Rights Campaign. "History was made tonight."
In Maine, Erica Tobey and Ali Ouellette wed in September, but only now will the women's marriage be recognized under Maine law.
"It's hard to overstate the national significance of this vote," Marc Solomon, campaign director at Freedom to Marry, said of the Maine referendum.
In Maryland, where just 51.9% of voters approved gay marriage rights, "It was a little bit pins and needles," said Human Rights Campaign's Kevin Nix. "It was going to be a close call all along."
A similar ballot measure in Washington state is pending. And in Minnesota, voters rejected a measure that would have banned same-sex marriage.
Pollsters got a hint of the coming change. Recent national surveys have shown shifting attitudes toward same-sex marriage, with a majority of Americans now approving of marriages between two men or two women. A June CNN/ORC poll, for example, reflected such a shift in opinion in the U.S.
Support has been growing for decades.
In the 1990s, most Americans told pollsters they did not know anyone close to them who was gay. By 2010, the number of Americans who said they had a gay or lesbian close friend or family member was 49%. This year, that number stands at 60%.
Election Day brought two additional gains for proponents of same-sex marriage: Wisconsin elected America's first openly lesbian senator, Democrat Tammy Baldwin, and President Obama became the first president to openly support same-sex marriage and get re-elected.
"I have never been this happy after an election in my 17 years of voting," said Derek Hurder from Hampden, Maine, who's been with his partner, Chris McLaughlin, for a year and a half.
They're not yet ready for marriage, but they were elated about having the option. And they both voted to re-elect the president.
The change in attitude makes them feel more comfortable, but that has its limits. "I wouldn't feel safe walking down the street holding hands," Hurder said.
Patane and Trinidad share their Catholic faith and are despondent that the church won't recognize their union.
"I believe in a religious marriage," Trinidad said. "I recognize that it's going to be a nonreligious wedding."
Tobey and Ouellette, who met four years ago, tied the knot last September -- in a church.
"We are affiliated with the United Methodist Church, which on the whole does not support same-sex marriage," Tobey said. But their church made a hearty exception. "We had three pastors who know us and love us and agreed to do that for us."
The legal situation led the couple to do things in reverse order. After their wedding, they applied for a name change. Now that the referendum has passed, they'll apply for a marriage license.
Maine should begin granting marriage licenses to same-sex couples in mid-December, according to same-sex marriage supporters at Freedom to Marry.
What the measures say
The two measures that passed, called "Question 1" in Maine and "Question 6" in Maryland, contain similar language.
The words man and woman "relating to the marital relationship or familial relationships must be construed to be gender-neutral for all purposes," the Maine measure says.
Maryland's ballot reads, "Civil marriage laws allow gay and lesbian couples to obtain a civil marriage license."
Both measures also explicitly mention the right of clergy to refuse to wed gay and lesbian couples if it goes against their religious convictions.
"This chapter does not require any member of the clergy to perform or any church, religious denomination or other religious institution to host any marriage in violation of the religious beliefs of that member of the clergy, church, religious denomination or other religious institution," Maine's Question 1 states.
The governments of Maine and Maryland had passed laws permitting same-sex marriage, but activists opposed to the laws collected enough signatures to put them on a ballot, said Fred Sainz, a spokesman for Human Rights Campaign, which raised $32 million for its campaigns on the referendums that included radio and television ads, social media strategy and on-the-ground canvassing by thousands of volunteers.
Opponents of same-sex marriage say the new laws in both states will redefine marriage for everyone as a genderless union and endanger the fabric of society.
"Such a radical change in the definition of marriage will produce a host of societal conflicts that government -- exercising its enormous enforcement powers -- will have to resolve," argues Maryland Marriage Alliance.
The group also published an online opinion by parents stating that legalizing same-sex marriage would lead to the promotion of homosexuality in school curriculum.
Sainz believes the campaigns supporting the Maine measure paid off.
In 2009, a similar referendum in Maine failed when voters rejected the governor's decision to allow same-sex marriage. Tuesday's results represent a remarkable turnaround.
"The secret to our success is that we won over hearts and minds," Sainz said. "Americans are fair and want to see their gay and lesbian friends, co-workers and family members have the freedom to marry."
Thirty-eight states have passed bans on marriages between people of the same gender, mostly by amending their constitutions to define marriage as a union between a man and a woman.
In the six states -- Massachusetts, Connecticut, Iowa, Vermont, New Hampshire and New York -- and the District of Columbia where gays and lesbians have previously won marriage rights, it was because of actions taken by judges or legislators, not voters.
On election night, Tobey joined friends as they all watched results on TV.
She wasn't expecting Maine's ballot to pass. But then they heard the news.
"I said: 'Hey, did that just happen?' "
She did a double take.
CNN's Rose Arce contributed to this report.