Under the measure, which the state House approved 61-54 before sending it on to the Senate for technical changes, gay weddings could be held in Illinois starting in June. The bill heads next to Gov. Pat Quinn, who has pledged to sign it but didn't immediately indicate when.
Fourteen states plus Washington D.C., allow same-sex marriage. Most recently, New Jersey, Minnesota and Rhode Island have legalized it.
The road to the Illinois vote was long with stalled attempts earlier this year, something that frustrated activists in the state where Democrats lead the House, Senate and governor's office. Chicago Democratic Rep. Greg Harris, who is the sponsor of the bill, decided not to bring the bill for a vote in May because he said he simply didn't have the support.
Then the U.S. Supreme Court ruled to strike down a provision of the federal Defense of Marriage Act, something he said resonated with lawmakers. Backers also launched a furious campaign, hiring a lobbyist from the state's largest union, the former head of the Illinois Republican Party and field organizers spanning the state.
"To treat all our citizens equally in the eyes of the law we must change this," Harris said on the floor. "Families have been kept apart."
Debate lasted more than two hours, and the final roll call was met with hearty cheers and applause. Supporters' speeches echoed themes of equality and civil rights with mentions of Obama, Martin Luther King Jr. and Matthew Shepard, a gay college student whose 1998 death sparked numerous hate crime bills.
Polls show support for gay marriage has surged since 1996, when Gallup found that 27 percent of Americans backed it. Now Gallup finds the majority support giving gay and lesbian couples the right to marry.
"Today the Illinois House put our state on the right side of history," Quinn said in a statement. "Illinois is a place that embraces all people and today, we are an example for the nation."
However, opponents of the legislation — which included some of the most powerful religious leaders in the state — have said marriage should remain between a man and a woman. A group of Chicago areas pastors vowed to line up primary challengers against some Chicago area lawmakers who voted yes.
"This issue is not just about two adults and their emotional relational and financial commitment to another," said Rep. Tom Morrison, a Palatine Republican. "Redefining marriage has far reaching implications in our society."
Three Republicans joined those voting in favor, including former House Minority Leader Tom Cross of Oswego who had not revealed how he'd vote ahead of Tuesday. The representative stepped down from his leadership position earlier this year and is seeking statewide office as treasurer.
"For me, supporting marriage equality is not only the right decision, but also consistent with my belief in individual freedom, equality and limited government," Cross said in a statement. He declined to talk with reporters.
Other lawmakers also came forward for the first time Tuesday, including Democratic state Rep. Jehan Gordon-Booth of Peoria, who wrote a newspaper opinion piece expressing her support as a matter of equality. State Rep. Linda Chapa LaVia told House members on the floor that she'd support the measure too.
The bill first cleared the Senate on Valentine's Day with the support of 33 Democrats and a single Republican. Backers had expressed confidence that the bill would be approved by the House in mid-March. But it took the supporters months to secure enough yes votes to win the House's approval.
In September, Minneapolis Mayor R.T. Rybak even went to Chicago to encourage gay couples to hold their nuptials in his city if they were tired of waiting for Illinois lawmakers to act.
Although Illinois once appeared poised to become the first Midwestern state to approve gay marriage in the Legislature, Minnesota did it sooner and started holding its first same-sex weddings over the summer. Iowa allows gay marriages too because of a court ruling, not a legislative vote.
The issue caused internal conflict among Illinois Republicans as the party works to balance efforts to appeal more to younger voters, minorities and women with the more socially conservative positions of some party members.
For months, the leaders of several black mega-churches lobbied the districts of black House members with an aggressive robocall campaign against gay marriage, placing an uncomfortable spotlight on the mostly Democratic black caucus. Many remained undecided until the vote neared.
On Tuesday, the African American Clergy Coalition praised those who voted against the measure.
"We will always believe that marriage is between one man and one woman," said Bishop Larry Trotter of the coalition. "Yet we will still love the members of the LGBT community."
Illinois approved civil unions in 2011.