Bill Clark via Getty Images For some reason, Rep. Steve Russell (R-Okla.) thought it made sense to add language to a defense bill that allows federal contractors to discriminate against people for being gay or transgender.

WASHINGTON ― The House passed a massive National Defense Authorization Act late Wednesday, and tucked inside of it, a provision that would allow federal contractors to fire employees for being lesbian, gay, bisexual or transgender.

The language, slipped into the bill by Rep. Steve Russell (R-Okla.), would dismantle President Barack Obama’s 2014 executive action that makes it illegal for government contractors to fire or harass employees based on their sexual orientation or gender identity. In its place, Russell’s provision applies a broad exemption that would open the door to contractors discriminating against LGBT people based on that contractor’s religious beliefs.

The government awards more than 2,000 contracts to religious organizations every year. Russell’s measure would affect every grant, contract and purchase order made by every federal agency, including contracts with hospitals, homeless shelters, colleges, schools, domestic violence shelters, and adoption agencies.

The House passed the 1,299-page bill, 277 to 147, with 142 Democrats and five Republicans opposed. At least one congressman, Rep. Mark Takano (D-Calif.), opposed it purely because of the anti-LGBT provision. He went on a bit of a Twitter rant ahead of the vote.

So now, voting to fund our nat'l defense means voting to force taxpayers to subsidize LGBT discrimination. But it’s worse than that...(4/x) — Mark Takano (@RepMarkTakano) May 18, 2016

It is ironic and sad that a defense bill would be used to undermine the very principles we are fighting to protect. (6/x) — Mark Takano (@RepMarkTakano) May 18, 2016

So let me be clear, under NO circumstances will I ever vote for a bill that promotes intolerance against a community of people. (10/x) — Mark Takano (@RepMarkTakano) May 18, 2016

Russell attached the language to the bill a few weeks ago, during a late-night House Armed Services Committee hearing. He argued that it's needed to clarify what he said was confusion in Obama's executive order over what kinds of legal protections are afforded to religious contractors. He also said Obama's order violates the First Amendment because it "unduly burdens the practice of religion." A copy of his amendment is here.

But Rep. Adam Smith (D-Wash.), the ranking Democrat on that committee, said that's not what Obama's executive order does at all.

"The way this amendment is written, it doesn’t matter if you’re a religious organization,” Smith responded. “Basically, you can be a private contractor, and this basically gives you the right to discriminate if you just decide that you don’t want to do business with gay people.”

Democratic leaders denounced the provision in the hours leading up to the vote. Minority Whip Steny Hoyer (Md.) said he was "outraged," and Minority Leader Nancy Pelosi (Calif.) called it "stunning" that Republicans would use a defense bill to "codify hatred and intolerance against Americans based on their sexual orientation or gender identity."

Some Republicans weren't happy about it, either. Rep. Charlie Dent (R-Pa.) tried to strip it from the bill during a Rules Committee hearing earlier this week. But the committee chairman, Pete Sessions (R-Texas), denied his request.

The bill now heads to the Senate, which has its own ideas about what belongs -- and what doesn't -- in an annual defense bill. Senators will hash out differences with the House later in a conference committee.

Obama has already threatened to veto the House bill and gave a long list of reasons why, including problems ranging from misuse of funds and operating the prison at Guantanamo Bay, to military pay raises and base closures. White House press secretary Josh Earnest said Tuesday that he couldn't single out any one item, such as the anti-LGBT provision, as grounds for a veto.

"There are a whole lot of reasons why the bill is bad," Earnest said in his daily briefing. "It’s unfortunate that it is being larded up with a bunch of proposals ... that aren’t related to our national security but are intended to be divisive."