WASHINGTON (Reuters) - The House of Representatives defied a White House veto threat on Tuesday and overwhelmingly passed legislation that would protect reporters from being jailed for refusing to reveal confidential sources.

By a vote of 398 to 21, the House sent to the Senate a bill that would prohibit prosecutors from forcing reporters to reveal confidential sources, except under limited circumstances.

"Freedom of the press is fundamental to our democracy and is fundamental to our security," declared House Speaker Nancy Pelosi, a California Democrat.

The margin of the House vote was more than the two-thirds majority needed to override a possible veto by President George W. Bush.

The bill was prompted by prosecutors' threats to jail reporters who didn't cooperate in several high-profile cases, including the BALCO steroid scandal in San Francisco and the CIA leak investigation in Washington.

The White House said the bill would hurt national security by making it too difficult to prosecute leaks of classified information.

Ironically, a shield law could have protected White House staffers who spoke to reporters, had it been in place when the Justice Department investigated who blew the cover of former CIA analyst Valerie Plame.

Former New York Times reporter Judith Miller spent 85 days in jail rather than divulge conversations she had about Plame with Lewis "Scooter" Libby, Vice President Dick Cheney's then-chief of staff.

Libby was ultimately convicted on four counts of perjury and obstructing justice in a case that was built on the testimony of other reporters after an appeals court ruled that they had no right to resist a subpoena.

Bush commuted Libby's prison sentence.

News organizations say a shield law is needed to prevent reporters from becoming de facto arms of law enforcement.

Abuses of power are less likely to come to light if reporters cannot promise confidentiality to whistle-blowers, congressional backers from both parties said.

Thirty-two states and the District of Columbia have shield laws, but federal laws offer no such protection.

Other reporters have spent up to seven months in jail to protect their sources.

The bill does not offer blanket protection. Reporters would have to turn over confidential information if it was needed to stop a terrorist attack, or identify its perpetrator afterward. A court could also force reporters to cooperate if it found that national security had been harmed.

The bill would only cover professional journalists who earn money from their news gathering. Members of terrorist organizations who claim to be journalists also would not be covered.