The House voted Tuesday in favor of so-called "clean" funding for the U.S. Department of Homeland Security, angering conservatives who wanted to tie the bill to restrictions on immigration reform.
The House passed the measure 257-167. The Senate passed it last week.
The bill now goes to President Barack Obama, who said it took Congress "far too long" to get it to his desk for his signature. He called Homeland Security workers "law enforcement professionals and brave patriots who do a remarkable job and deserve our gratitude and respect."
Tuesday's House vote came after Speaker John Boehner reportedly told fellow Republicans that shutting down an agency responsible for preventing a terrorism attack was not an option.
The bill fully funds the Department of Homeland Security for the rest of the fiscal year. If the bill had failed, the agency responsible for safeguarding the nation's borders and airports and protecting the president would have run out of money Friday.
The agency would have had to furlough about 30,000 employees, and more than 200,000 would have been forced to work without pay.
Funding had been hung up on the insistence of some conservative Republicans to attach demands to stop Obama's executive order to end deportations for some people who had immigrated to the U.S. illegally.
Senate Democrats had refused to accept the bill with the immigration measure attached and Obama had said he would veto it.
Democratic Senate Minority Leader Harry Reid praised the House for Tuesday's vote.
"Common ground should be something we seek, not run away from, especially when the security of the nation is at stake," he said.