ST. PAUL — Gay couples will be permitted to wed in Minnesota starting in August, making it the 12th state to permit same-sex marriage and the first in the Midwest to take such a step outside of a court ruling.

The State Senate, controlled by Democrats, voted 37 to 30 on Monday to allow same-sex marriages, after approval by the State House last week. Gov. Mark Dayton, also a Democrat, had urged lawmakers to pass the measure and said he would sign the bill on Tuesday afternoon.

“In my heart of hearts, I know that today love wins,” State Senator Tony Lourey, a Democrat, said Monday during a tense, often personal debate before the vote. Hundreds of people on both sides of the issue packed the halls of the Capitol here, chanting, cheering and waving signs with clashing messages — “Don’t Erase Moms and Dads” and “Marriage Equality, You Betcha.”

Supporters portrayed the choice as a historic decision on the biggest civil rights question of this era and as a simple matter of fairness, while opponents said that the bill carried numerous unintended consequences and that Minnesotans needed more time to weigh such a divisive matter.