Hours after the Senate passed its measure, the House voted 285 to 144 to approve the Senate plan, which would fund the government through Jan. 15 and raise the debt limit through Feb. 7.

Most House Republicans opposed the bill, with the party splitting 87 in support and 144 against. The breakdown showed Republican leaders were willing to violate the Hastert rule, their informal rule against advancing bills that do not have majority Republican support, in order to end the shutdown. All 198 Democrats voting supported the measure.

House members debated the measure for a half-hour before the vote.

Representative Nancy Pelosi of California, the Democratic leader, urged members to vote for the bill, which she said was “the best we can do,” and accused House Republicans of recklessness for shutting down the government and risking default on the nation’s financial obligations.

“My colleagues, do you think that your recklessness was worth $24 billion to our economy?” she said.