The House voted 357-60 in favor 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 deadline.
Earlier, Republicans had rejected a similar three-week extension after provisions against President Barack 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 Barack 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.
Some Republicans had wanted to use the funding of the department, which includes immigration officials, as a bargaining chip to force President Barack Obama to end policies on immigration.
In November 2014, Barack Obama used his executive powers to protect about five million undocumented immigrants from deportation. Republicans say President Barack 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.
On February 26, 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,” Jeh Johnson said.
Last week, the White House said President Barack Obama would prefer a full funding bill but would sign a short-term measure to prevent a shutdown.
d4lS-LI9wXYImage source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…