The US Homeland Security Department has avoided a partial shutdown as Congress passed a one-week funding extension, hours before a midnight deadline.
The House of Representatives voted 357-60 in favour of the short-term bill after it had been passed in the Senate.
President Barack Obama, who said he would back a short-term deal to avert a shutdown, signed it shortly afterwards.
It ensures the department’s 250,000 employees will be paid while a longer-term funding agreement is discussed.
The two-thirds majority vote was reached about two hours before the midnight (05:00 GMT Saturday) deadline.
Earlier, Republicans had rejected a similar three-week extension after provisions against President Obama’s immigration plan were dropped.
The one-week deal was backed by a majority of Democrats despite many of them voting against the earlier bill in the hope that a longer-term deal could be agreed.
The move came shortly after President Obama had spoken by phone to Democratic leaders in a bid to avert the partial department closure.
The Department of Homeland Security is responsible for securing US borders, airports and coastal waters.
About 200,000 “essential” department employees would have continued to work without pay if the agency’s funding had not been secured.
Effects Of A Homeland Security Shutdown
Airport security agents required to work without pay Employers would not have the ability to use a programme called E-Verify to check if new employees are authorised to work legally in the US No grants made to local and state authorities, including for training and new equipment Secret Service will not be able to hire agents to protect 2016 presidential candidates Civil rights and civil liberties complaint lines and investigations will be shut down
Some Republicans had wanted to use the funding of the department, which includes immigration officials, as a bargaining chip to force President Obama to end policies on immigration.
Last November, Mr Obama used his executive powers to protect about five million undocumented immigrants from deportation. Republicans say Mr Obama overstepped his powers in doing so.
A separate ruling by a federal judge has blocked those policies from starting while a lawsuit by more than two dozen states goes forward.
Some Republicans senators had expressed a desire to fight the executive actions in the courts, rather than threaten the department’s funding.
The BBC’s Naomi Grimley in Washington says many on Capitol Hill feared a public backlash if the funding had been thrown into doubt at a time of fears about “lone wolf” terrorists.
On Thursday, Homeland Security Secretary Jeh Johnson urged Congress to pass full funding.
“A short-term continuing resolution exacerbates the uncertainty for my workforce and puts us back in the same position, on the brink of a shutdown just days from now,” Mr Johnson said.
Last week, the White House said Mr Obama would prefer a full funding bill but would sign a short-term measure to prevent a shutdown.