Gov. Rick Perry announced Wednesday that he signed legislation protecting journalists from having to reveal certain confidential sources in court.

The shield law, known as the Free Flow of Information Act, grants a qualified privilege to journalists so they can protect their sources and in many cases not have to testify or produce notes and tapes in court gathered while acting as a journalist. News industry and open government advocates fought for the law for several legislative sessions.

Thirty-six states and the District of Columbia had some form of shield law. Texas becomes the 37th state.

Supporters of the measure say it will encourage whistleblowers to come forward and reveal government corruption, public safety hazards and corporate malfeasance because they will know their identity can be protected.

“It’s an important day for Texas,” said Fred Hartman, chairman of the Texas Daily Newspaper Association/Texas Press Association legislative advisory committee. “It’s a law that will benefit all Texans, all of our citizens.”

The law takes effect immediately.

The House and Senate overwhelmingly approved the bill, sending it on to Perry for his decision.

“This was a complex issue that required thoughtful consideration, and I am pleased that lawmakers were able to strike a balance between protecting the rights of the people and the press,” Perry said in his announcement. The Republican governor praised Democratic Sen. Rodney Ellis of Houston and Democratic Rep. Trey Martinez Fischer of San Antonio, sponsors of the bill.

Ellis called it a historic day. Texas “finally stood behind the principle that the press plays a vitally important role in our democracy and must be protected from government intimidation,” he said.

For a long time, prosecutors opposed the law, saying it would prevent them from gathering evidence in criminal cases. But in a marathon meeting earlier this spring they reached a compromise with news industry and open government advocates.

Under the new law, there are exceptions to the journalist privilege.

For instance, news reporters must identify a confidential source in a criminal case if the journalist observed the person committing a felony, if the source confessed to committing a felony or if there is probable cause to believe the source committed a felony and the prosecutor has exhausted all efforts to obtain the identity.

Working out an agreement with the district attorneys association and passing the bill early in the legislative session were key to achieving the new law, said Laura Prather, president of the Freedom of Information Foundation of Texas. She said advocates spent past sessions laying groundwork and educating the public, providing momentum going into the 2009 session.

“This will create a system in which people who know about wrongdoing will feel comfortable coming forward and reporting that wrongdoing, and it will benefit all Texans,” said Prather, an Austin-based media attorney. “It has been a tremendously long process. We’ve learned a lot on the way.”