The US Congress passed a temporary, last-minute bill to avert a partial shutdown of the Department of Homeland Security (DHS) late on Friday night, as a stand-off over President Barack Obama's immigration policies continued to rock the Capitol.

The House of Representatives approved the measure 357-60 late on Friday, after it easily cleared the Senate without a roll call.

Although Obama had time to sign the bill just before the midnight deadline, the deadlock could be repeated in just a week.

"You have made a mess," House Democratic Leader Nancy Pelosi told Republicans as the midnight deadline loomed.

"There are terrorist attacks all over the world and we're talking about closing down Homeland Security. This is like living in world of crazy people," Rep. Peter King of New York, a former chairman of the Homeland Security Committee, tweeted in agreement.

The deal ensures that the departments 250,000 employees will be paid while a long-term funding agreement is resolved.

The chaos was caused as Democrats and Republicans remained locked in a dispute over an executive order Obama passed in November removing the threat of deportation for the 4.7 million undocumented US residents.

The Republicans had previously rejected a three-week extension after their attempts to shoehorn a provision into the spending bill to overturn the immigration order failed.

It was a devastating blow for Speaker John Boehner and the House Republican leadership, which refused to allow a vote on a bipartisan Senate amendment that would have funded DHS through September.

The Senate presented the week-long alternative to keep the agency open. It was backed by a majority of Democrats, although many had voted against the earlier bill in the hopes of agreeing a longer-term deal.

The DHS's mission is to prevent terrorism and enhance security, manage US borders, administer immigration laws, secure cyberspace, and ensure disaster resilience.