For the first time in history, the U.S. Senate approved a bill that would outlaw discrimination in employment based on sexual orientation or gender identity.

The final vote was 64-32 in favor of passing the Employment Non-Discrimination Act on to the House of Representatives, according to CSPAN.

All 55 Senate Democrats voted for the bill, as did nine Republicans, including surprise "aye" votes from Sens. John McCain and Jeff Flake, both of Arizona.

As debate came to a close Thursday afternoon, senators voted down an amendment from Pennsylvania Republican Pat Toomey that would have expanded the number of groups and individuals who could discriminate against LGBT people based on religious beliefs failed by a vote of 43-55.

Toomey, who voted to invoke cloture and begin debate on the bill earlier this week, said he believed his amendment made an effort to relieve tension between "two vitally important American values": equality and religious liberty. In explaining how his amendment would affect the scope of the law, Toomey noted that some religious-run organizations take part in secular activities but should still be exempted from adhering to ENDA's nondiscrimination orders.

"I think the agreement is that religious institutions, including those engaging in some secular activities, should be exempt from engaging in activities that contradict their religious beliefs," Toomey said on the Senate floor Thursday. Toomey offered examples of such instances where businesses serving the public should be allowed to discriminate, including a gym run by the Mormon Church, a Presbyterian-run retirement home, or a Jewish community center.

Several Democratic senators took the floor in opposition to the amendment, noting that the chamber already approved language exempting faith-based organizations and clergy from ENDA's discrimination protections.

"This amendment threatens to gut the central premise of ENDA," said Sen. Tom Harkin of Iowa, who opposed the amendment. "The amendment is ill-defined, and opens floodgates to all kinds of court cases."