Republicans came under pressure after a bipartisan amendment was attached to the bill that protected federal workers from being fired on the basis of sexual discrimination or gender identity.
In a sign of how passionately opponents felt about the provision, a Georgia Republican member opened an early morning meeting with a prayer that warned colleagues that any House GOP member who backed the LGBT provision "was going to hell." The remarks offended some, prompting them to walk out of the meeting, according to GOP sources who attended.
The controversial social debate could jeopardize future efforts to pass spending bills.
House Republicans had scrambled last week to defeat a similar Democratic proposal to protect federal LGBT workers as part of another spending bill for military construction and veterans program. During that vote, the House floor erupted in jeers from Democrats after the vote board showed the LGBT amendment had the votes to pass, but GOP leaders kept the vote open and convinced several members to switch their votes to defeat the proposal.
Republicans argued they didn't want it to pass because it was an amendment to the annual military construction and veterans spending bill and could have jeopardized support for that legislation.
But when the proposal was offered again to the energy and water funding bill, it was approved on a 223-195 vote with 43 Republicans supporting the amendment.
Democratic New York Rep. Sean Patrick Maloney, who sponsored both LGBT proposals, vowed to continue to offer similar amendments to future spending bills. He criticized Republicans who rejected his proposal.
"I think we are living in a new world of Donald Trump and a Republican Party that is driving itself further and further away from common sense and further towards a radical approach to government," Maloney told reporters.
Arizona GOP Rep. Trent Franks, who opposed the bill, told CNN that Maloney's amendment "codifies an extra-Constitutional executive order by President (Barack) Obama that would create a new protected class and I think would polarize our society in ways that are completely unnecessary."
In an effort to counter the LGBT provision and prevent Republicans from opposing the bill, two amendments were added to offer members to express their views on the controversial social issue.
North Carolina GOP Rep. Robert Pittenger proposed an amendment that backed the law in his home state. That so-called "bathroom law" blocked cities from allowing transgender individuals to use public restrooms for the sex they identify as -- as well as restricting cities from passing nondiscrimination laws more broadly. Pittenger's amendment passed, as well as an additional GOP proposal that allowed religious institutions an exemption from enforcing LGBT-specific provisions.
Democrats decried those changes, and 175 joined with 130 Republicans to sink the bill. It failed, 112-305.
Ryan blamed Democrats for the measure's defeat, saying they "were not looking to advance an issue but to sabotage the appropriations process."
For the second week in a row, the House wrestled with an issue that exposed divisions inside the Republican Party about how to address discrimination against the LGBT community.
Maloney told reporters that a Republican told him on the House floor that in a Thursday morning GOP meeting to discuss the upcoming vote on the spending bill, one House Republican cited the Bible and warned fellow GOP members who backed it were "going to hell."
Two GOP sources told CNN that Georgia Rep. Rick Allen's comments during the opening prayer upset some Republicans who opted to walk out. One of these sources, who didn't hear a specific reference to "hell," emphasized the views expressed by Allen are "not reflective of the views of the conference."
A spokeswoman for Allen told CNN, "the congressman led the prayer and pledge this morning in conference. He made no reference to the amendment or the bill."
Franks said he believed Republicans could work on some sort of compromise plan to address concerns about discrimination broadly and still approve spending bills.
House Appropriations Chairman Hal Rogers told reporters he planned to "reset" and try again to bring up more spending bills.
But multiple Republicans acknowledged that it would be difficult to move additional spending bills because the same issue is likely to trip them up. Congress is likely instead to have to take up some type of "continuing resolution" to keep federal agencies funded and avoid a government shutdown when money runs out at the end of September.