The House has approved a bill to fund the Homeland Security Department for one week, with just two hours before a midnight deadline.

The measure now goes to President Barack Obama for his signature.

The vote late Friday was 357-60 as Democrats joined majority Republicans in backing the bill that averts a partial government shutdown.

The vote was a turnaround from a few hours earlier, when tea party conservatives rebelled against GOP leaders and helped sink a measure that would have ensured full funding for the agency for three weeks.

Democrats had opposed that measure, arguing that the department should be funded through the end of the budget year on Sept. 30.