At first, it looked like a long shot.

It’s just too soon, some DFL leaders were saying at the beginning of the year. Then polls confirmed as much: A majority of Minnesotans was uneasy too.

Now Minnesota is on the cusp of becoming the 12th state in the nation to make same-sex marriage legal.

Last week, by a surprisingly comfortable margin, House members approved the measure in a raucous, emotional day of debate, the likes of which are rarely seen at the Capitol. On Monday, the DFL-led Senate is poised to follow suit, with even GOP leaders conceding the votes are there. If the bill passes the Senate, DFL Gov. Mark Dayton could sign it into law by Tuesday.

“I feel like I’ve just watched a revolution from start to finish,” said the Rev. Meg Riley, a Unitarian Universalist minister who has campaigned for marriage equality for more than half of her 57 years.

If so, it’s a revolution that stemmed from an intensive, mostly behind-the-scenes campaign to persuade DFLers — and a handful of GOP legislators — that now is the time to grant gay and lesbian couples the right to legally wed. Its success also is due to a decision by a key DFL leader to abandon efforts to pass new gun laws, relieving lawmakers from conservative areas of hard votes on two divisive social issues.

Fast turnaround

The turnaround on same-sex marriage has been dramatic.

Just two years ago opponents seized a surprise opportunity to try to permanently ban it in Minnesota.

After winning unprecedented control of both chambers in the Legislature, Republicans decided to ask voters to approve a constitutional amendment that would permanently make same-sex marriage illegal.

The amendment touched off the most ferocious battle of the 2012 elections in the state, galvanizing activists on both sides and drawing millions of dollars in campaign spending.

In a stunning defeat, Minnesota voters rejected the measure, the first to do so among the 31 states that have voted on the question.

When it was over, gay marriage remained illegal. Unwilling to waste momentum, Minnesotans United for All Families, the lead group pushing for same-sex marriage, moved quickly to hire a dozen seasoned lobbyists to press its case at the Capitol, including several with deep Republican ties.

Then a fresh obstacle arose: DFLers had won control of the House and Senate and wanted to make overdue budget issues their priority.

They were jubilant at the amendment’s defeat but wary of legalization.

Many advocates at the Capitol advised waiting three, even five years on the marriage issue, said Richard Carlbom, campaign manager for Minnesotans United.

Carlbom started meeting with DFLers to discuss the politics and ethics of the issue. “Once you decide that somebody is being denied a basic freedom, how in the world can you say, ‘We are going to let it wait another year?’ ” he said.

Slowly, Carlbom made inroads, but his group remained a long way from a majority.

Rural DFLers were a particularly tough sell, coming from districts where a move to redefine marriage cut against bedrock religious values.

“Public opinion is changing, but it’s just slower in greater Minnesota,” said Rep. Jay McNamar, an Elbow Lake DFLer who first revealed his position when voting for same-sex marriage last week.

Guns and gays

Then another issue surfaced that shattered already fragile party unity: the mass shooting at Sandy Hook Elementary School in Newtown, Conn.

Suddenly, some DFLers were rolling out tough new gun legislation, proposals fiercely opposed by the National Rifle Association and a powerful group of rural DFL legislators.

Democrats fought bitterly among themselves for weeks, divided over the two explosive issues, guns and gay marriage.

With his caucus seemingly deadlocked on both issues, DFL House Speaker Paul Thissen made a surprise announcement.

He declared the gun issue dead for the year, a rarity in an institution where nothing is considered dead until the session is over.

Several legislators said Thissen’s announcement was a subtle but important breakthrough for the marriage issue, a personal priority for Thissen and other top DFLers.

“The gun issue was muddying the marriage issue,” said Rep. Tom Anzelc, DFL-Balsam Township.

He said several DFLers had argued passionately behind closed doors against bringing marriage up for a vote this year. They feared it would be too politically damaging for rural members and could cost the party its hard-won majority.

Anzelc said that a tough vote on gay marriage plus an equally difficult vote on gun control could be political suicide for some legislators.

Once the gun issue went away, he said, shaky rural members had time to reconsider the same-sex marriage issue and their place in history.

Ultimately, most of them — including the NRA’s highest-rated DFL members — voted for same-sex marriage, adding the crucial margin that solidified the bill’s passage.

“I just don’t think many people could have done that with the catastrophic social issue of guns hanging out there unresolved,” Anzelc said.

Rep. Michael Paymar, DFL-St. Paul, a gun-control advocate, remains upset that none of his proposals will get a vote by the full House.

“I am sure that there are people in this caucus who would have a hard time voting for both” gay marriage and gun control, he acknowledged.

House Majority Leader Erin Murphy, DFL-St. Paul, maintains that guns and gay marriage were never formally linked.

“The issues were definitely dealt with separately,” she said.

Hunting for GOP votes

With DFL votes locked up, Minnesotans United turned its attention to securing a handful of Republicans.

Going into last week’s vote, not a single GOP House member had publicly supported allowing same-sex marriage.

Behind the scenes, several Republicans reached out to Minnesotans United to see whether a deal could be struck.

They said they had looked at the political tides and decided passage was inevitable. They consulted friends, political mentors and faith leaders.

But several sought an added comfort level: language that would make clear the new law would address civil marriages only, not those performed by churches.

Same-sex marriage advocates were leery.

They had no guarantee the changes would persuade any Republican lawmakers to come aboard.

Finally, supporters concluded that a bipartisan vote was worth adding the word “civil” in front of marriage.

The Friday before the vote, Minnesotans United’s spokesman Jake Loesch celebrated his birthday at the Eagle Street Grille in downtown St. Paul.

Loesch is a devoted Republican, and the gathering featured a number of former Minnesotans United campaign staffers and Republican operatives.

The raucous event drew one surprise guest: State Rep. David FitzSimmons, R-Albertville. Few knew, but FitzSimmons had been working behind the scenes with others to craft the “civil” amendment.

When the House floor vote came, FitzSimmons reached over and pushed the green button on his desk, joining three other Republicans in the momentous vote to legalize same-sex marriage.