ST. PAUL, Minn. (AP) — Gov. Mark Dayton on Tuesday signed a bill making gay marriage legal in Minnesota, the 12th state to take the step, as thousands of onlookers cheered.

"What a day for Minnesota!" Dayton, a Democrat, declared moments before putting his signature on a bill. "And what a difference a year and an election can make in our state."

Rainbow and American flags flapped in a sweltering breeze during the ceremony, held on the Capitol's south steps. The crowd, estimated by the State Patrol at 6,000, spilled down the steps and across the lawn toward downtown St. Paul.

Dayton thanked legislators for "political courage" before signing the bill just a day after it passed the state Senate. It passed the House last week.

The push for gay marriage was a rapid turnabout from just six months ago, when gay marriage supporters had to mobilize to turn back a proposed constitutional amendment that would have banned gay marriage. Minnesota already had such a law, but an amendment would have been harder to undo.

But voters rejected the amendment, and the forces that organized to defeat it soon turned their attention to legalizing gay marriage. Democrats' takeover of the Legislature in the November election aided their cause.

The two main sponsors of the bill, Rep. Karen Clark and Sen. Scott Dibble, were among the onlookers as Dayton signed, capping their long and often discouraging struggle to advance gay rights.

Clark, 67, was first elected to the Legislature in 1980, a decade after she came out of the closet to her parents. In 1993, her by-then elderly parents marched with her in the Minneapolis gay pride parade a few weeks after she led the effort to extend Minnesota's civil rights protections to gay people.

But by 1997, the same Legislature passed the "Defense of Marriage Act," which restricted marriage to only opposite-sex couples. A year later, Clark introduced a bill to repeal it and allow gay marriage.

It took 16 years to get to this week, which comes two years after the 2011 Legislature — then controlled by Republicans — put an amendment on the statewide ballot asking voters to cement the existing gay marriage ban in the state constitution.

Story continues

"I thought it would happen someday, but I didn't know I would be able to be here to be part of it," Clark said hours before the ceremony.

While on the House floor last week defending her quest to legalize gay marriage, she won plaudits even from Republicans opposed to the bill.

"I don't know of a kinder, more gentle woman on this floor that has a bigger heart for the environment, the underprivileged, the downtrodden, the American Indian, especially the women. I admire you," said Tony Cornish, a longtime Republican representative from rural southern Minnesota.

"It was hard because it was very personal," Dibble said of the 2011 vote. "People whom I had counted as very, very good friends voted for it."

Dibble, 47, graduated from high school in the Minneapolis suburb of Apple Valley and came out in college. He cut his teeth politically in the late 1980s as a member of the Minnesota chapter of ACT UP, a gay civil rights group that engaged in civil disobedience out of anger toward government neglect of AIDS and HIV sufferers. He got an early chance to join the establishment from Clark, who tapped him to run one of her re-election campaigns.

"I pulled him from street politics," she said. Dibble was elected to the House in 2000, and in 2002 to the state Senate. He holds the southwest Minneapolis seat once occupied by the late Allan Spear, who in 1974 became one of the very first U.S. elected officials to come out of the closet.

While Dibble's district includes many of the city's trendiest neighborhoods, Clark's just to the east is marked by public housing towers and large populations of new immigrants.

"She is a huge, huge voice for the poor and the disenfranchised and the dispossessed," Dibble said. But she continued through her career to make a mark for gay rights: During former Republican Gov. Tim Pawlenty's 2006 State of the State speech, Clark stood up on the House floor and turned her back to the governor as he endorsed a constitutional ban on gay marriage.

Not long after that, the first stirrings of legal same sex marriage started to surface around the country. In 2008, Dibble and his husband, Richard Levya, were married in California, where Levya is still a part-time resident. While a judge later struck down gay marriage in that state, marriages that already occurred were not nullified.

Dibble said they won't remarry in Minnesota, but will have an affirming ceremony.

But Clark and Jacquelyn Zita, her partner of 24 years, plan to make it official in Minnesota. They haven't picked a date, but Clark envisioned a wedding on the farm they own north of Minneapolis.

"It will be small, probably just friends and family," Clark said. "We're actually very private people."

___

Follow Patrick Condon on Twitter at http://twitter.com/pcondonap .