Media companies and journalism groups have argued that the measure is needed to keep the public informed about government corruption, but the Bush administration and other opponents say it could harm national security.
Under the measure, federal courts would join 32 states and the District of Columbia in protecting reporters from being forced to reveal confidential sources, except in certain cases.
The voice vote sent the bill, sponsored by Reps. Rick Boucher, D-Va., and Mike Pence, R-Ind., to the House floor.
Supporters said whistle-blowers will be less likely to provide information about government and other wrongdoing if reporters are required to give up their sources.
The bill "helps restore the independence of the press so that it can perform its essential duty of getting information out to the public," said Judiciary Committee Chairman John Conyers, D-Mich.
Opponents said the bill leaves open too many possibilities in which reporters might be exempted from having to provide information that might help the government hunt down terrorists or for use in libel cases.
"We should not create a protection so broad that those who would destroy people's reputations, businesses and privacy can hide behind it," said Rep. Lamar Smith of Texas, the committee's senior Republican.
The Justice Department opposes the bill.
Reporters can still be compelled to provide their source in certain circumstances that are listed in the article.
Bloggers are not protected if their blogs do not provide them with their livelihood, and the language is vague at best to address the issue of a government official breaking the law by divulging classified information.