"It was over five," Madigan said, adding that it was not over 10.

In addition, African-American lawmakers who had been divided on the issue provided some key votes in favor, and three House Republicans came onboard.

The speaker gave much credit to Harris, the bill's sponsor, saying he was steadfast in the face of "unwarranted criticism" from some in the gay community who were not happy with the way Harris was handling the bill. Some activists had demanded Harris call the bill whether the support was there, contending failure to do so should result in his resignation. Madigan said those efforts "did not help the passage of the bill, it probably hurt the passage of the bill."

Harris said he was focused on the broader outcome.

"Often you have to take a long view and say, 'This is where we need to go, this is the destination,'" he said.

Under the measure, the definition of marriage in Illinois would change from an act between a man and a woman to one between two people. Once signed, civil unions could be converted to marriages within a year of the law going on the books. The legislation would not require religious organizations to wed gay couples, and church officials would not be forced to allow gay couples seeking to marry to use their facilities.

But opponents say the bill doesn't go far enough to protect religious rights. For example, they contend religious groups may be forced to provide health insurance to an employee's same-sex spouse. Others say the bill offers no protections for people like bakers, florists and wedding photographers who may oppose same-sex marriage and could open themselves up to legal action for refusing to provide services.

"The fact is that this bill is the worst in the U.S. for protecting religious liberty," said Rep. Jeanne Ives, a Republican from Wheaton.

The vote was expected to be so tight that Rep. Naomi Jakobsson, an Urbana Democrat, rushed to Springfield from her home where she said she was caring for an ill relative. Jakobsson, a co-sponsor of the legislation, made it to the House floor shortly after the debate started. One lawmaker, Democratic Rep. Emily McAsey from Lockport, brought her infant onto the floor.

While the galleries weren't nearly as packed as when a vote was expected in May, dignitaries packed the floor to watch the vote unfold, including Quinn, Lt. Gov. Sheila Simon, Attorney General Lisa Madigan and Republican Comptroller Judy Baar Topinka.

Arguments during the 2 1/2 hours of debate were often eloquent and mostly respectful.

Republican Rep. Dwight Kay, of Glen Carbon in southwestern Illinois, called on lawmakers to "stick by" their convictions rather than walk away for the "expediency of the moment."

"You shouldn't deny your own experience or your own conviction," Kay said. "My conviction happens to be that this (gay marriage) is wrong, but my conviction is that Scripture is right."

Rep. Ken Dunkin, chairman of the legislature's black caucus, countered Kay's remarks, saying it was not long ago that discrimination was ingrained in laws that denied rights to African-Americans.

"Jesus loved everyone," Dunkin said.

House Majority Leader Barbara Flynn Currie likened the denial of gay marriage to laws against interracial marriage decades ago.

But Rep. Mary Flowers, D-Chicago, lashed out at efforts to equate the fight for same-sex marriage with the civil rights movement.

"Homosexuality has nothing to do with race," Flowers said. "This debate is a joke."

Rep. Sara Feigenholtz, D-Chicago, said the issue mattered very much to the families that would be impacted, reading a letter from a 10-year-old girl being raised by a gay couple who asked, "Will you let my two dads be married?"

Rep. Lou Lang, a Democrat from Skokie, said the matter came down to love.