The so-called "omnibus" funding bill, which easily passed in the Senate, also in the process gave congressional approval to the landmark Cybersecurity Act.
The measure was approved with blessings from the White House, over objections of privacy activists.
Officials with the House Homeland Security Committee said in a statement that the bill would protect America's private sector and federal networks "which are under continuous threat from foreign hackers and cyber terrorists."
Separate versions of the bill were approved earlier this year by the Senate and House of Representatives.
More From This Section
"This streamlines the federal government's ability to more effectively identify and thwart cyber-attacks," he said.
President Barack Obama would get a victory with the approval after several years of seeking legislation to boost cybersecurity. Previous efforts were bogged down by opposition from activists who feared it would result in excessive government intrusion, and conservatives who argue it would create a new bureaucracy.
Obama welcomed the measure, a senior US official said. "The president has long called on Congress to pass cybersecurity information-sharing legislation that will help the private sector and government share more cyber threat information by providing for targeted liability protections while carefully safeguarding privacy, confidentiality, and civil liberties," the official said.
A key element in the legislation would shield private companies from liability if they report or share information about cyber threats.