On Tuesday, Minnesota became the 12th state to legalize gay marriage as Governor Mark Dayton signed a bill into law on the front steps of the Capitol in St. Paul.

A large crowd chanted “thank you” as the governor put pen to paper, ending two years of back-and-forth and the issue.

“What a day for Minnesota!” Dayton, a Democrat, told the crowd, estimated at 6,000. “And what a difference a year and an election can make in our state.”

The Minnesota Senate approved the measure on Monday, 4 days after it cleared the House.

The issue has molded Minnesota politics like no other in recent times, taking it from blue to red and back again in 2 years.

In 2010, marriage equality foes campaigned heavily in the state as Democrats increasingly came out in support of the issue.

That year, conservative Republican majorities regained control of the House and Senate and immediately began pushing for a referendum on a constitutional amendment which sought to define marriage as a heterosexual union.

Amendment supporters balked when the GOP rejected broader language aimed at banning recognition of any union other than marriage, which would have closed the door to civil unions or domestic partnerships for gay and lesbian couples.

Minnesota voters, in a first, rejected the amendment last fall and returned the House and Senate to Democrats.

The stunning rebuke set the stage for a new push to make Minnesota a marriage equality state.

Passage makes Minnesota the first Midwestern state to legalize such unions with a legislative vote.

Gay and lesbian couples can begin marrying on August 1, the same day Rhode Island's marriage law takes effect.