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.