“The Republican defense authorization bill before the House is both bad budgeting and harmful to military planning — perpetuating uncertainty and instability in the defense budget, and damaging the military’s ability to plan and prepare for the future,” Ms. Pelosi wrote. “Republicans should come together with Democrats in a fiscally responsible way to protect our national security and grow our economy.”

President Obama has threatened to veto the legislation, which Defense Secretary Ashton B. Carter last week described as “clearly a road to nowhere.”

Mr. Boehner urged Democrats to support the bill, saying it should not be “a tough vote.”

“This vote is about whether you support our men and women in uniform,” Mr. Boehner told reporters Thursday.

Republicans, however, also faced one major obstacle, in the form of pro-immigration language that Representative Ruben Gallego, Democrat of Arizona, attached to the bill in a bipartisan committee vote. Mr. Gallego, a Marine Corps veteran, offered an amendment that would have allowed Congress to encourage the Pentagon to consider allowing young undocumented immigrants known as Dreamers to serve in the military.

Despite the provision having, in the words of Mr. Gallego himself, “no teeth,” roughly two dozen Republicans, led by Representative Mo Brooks of Alabama, warned that the amendment could sink the entire bill, and Mr. Brooks offered an amendment of his own to strip out Mr. Gallego’s language. On Thursday evening, Mr. Brooks’s amendment passed, 221 to 202, helping pave the way for the military spending bill’s final passage. Twenty Republicans voted against the Brooks amendment.