House Republicans' plans for next year's Veterans Affairs and military construction spending were nearly undone Thursday due to an ongoing fight over protections for gay and transsexual workers in federal contracting law.

It's the second time this week the that issues of discrimination and religious freedom became entangled in defense legislation in the chamber. In a late Wednesday voting session, Democrats unsuccessfully tried to block a related provision from the annual defense authorization bill, and largely voted against the annual measure as a result.

Hours later, Rep. Sean Maloney, D-N.Y., broached the topic again during debate on the first defense appropriations measure to reach the House floor this year.

His amendment would have prohibited federal contractors from discriminating against workers on the basis of sexual orientation. It was in opposition to Republican-backed language from Wednesday night, which stated federal contractors cannot be discriminated against on the basis of religion.

Maloney's amendment failed 212-213, after several Republicans appeared to switch their position while a vote was held open well past the announced timeline. Democrats on the floor chanted "Shame! Shame!" as the process slowly unfolded.

House Democratic Whip Steny Hoyer, D-Md., called the process "undermining democracy" and accused Republicans of "switch votes so that discrimination could prevail."

After a series of partisan procedural stalling tactics, the appropriations bill passed 295-129, with all of the opposition coming from Democrats.

The White House has already threatened a veto of the appropriations bill, stating concerns over the shortfalls in the $184 billion spending plan and restrictions included on White House plans to close the detention facilities at Naval Base Guantanamo Bay, Cuba.

The plan includes $73.5 billion in discretionary spending for the Department of Veterans Affairs next year, $1.8 billion above the fiscal 2016 level but $1.2 billion below the president's budget request.

VA leaders have called that trim from the White House request a hazardous squeeze on department programs next year, and have instead backed Senate appropriators' plan to match that request.

The Senate is expected to vote on its version of military construction and VA funding measure in coming days.

Leo Shane III covers Congress, Veterans Affairs and the White House for Military Times. He can be reached at lshane@militarytimes.com.