When two New York Times reporters learned in 2004 that the George W. Bush administration was secretly wiretapping Americans, and collecting their phone and email records, the reporters’ attempt to publish their findings were thwarted by the administration’s intense and successful lobbying of their editors.

In that effort, the Republican president had an unlikely ally: Rep. Jane Harman of Los Angeles, the senior Democrat on the House Intelligence Committee. Harman, now the president of a research organization in Washington, D.C., asked recently about her intervention, expressed no regrets.

“There are times when classified materials must be protected,” she told The Chronicle.

Details of the far-reaching, legally unauthorized surveillance program remained secret until the Times published the article in late 2005, more than a year after Bush was narrowly elected to a second term.

The program’s secrecy made court challenges virtually impossible, except for the rare occasions in which surveillance led to criminal charges. Congress authorized the program in 2008 while narrowing it somewhat.

The newspaper’s interactions with administration officials, and Harman’s role, were described by former Times reporter James Risen this month in the Intercept, the investigative publication where he now works.

Risen said he and Times colleague Eric Lichtblau had learned in the summer of 2004 that the National Security Agency, with Bush’s approval, was wiretapping Americans in cases of alleged terrorism without seeking legally required judicial warrants, and was also collecting email and phone records of millions of Americans.

The story on the program known as Stellar Wind was ready for publication before the November 2004 election, when Bush was on the ballot, but NSA Director Michael Hayden and other administration officials told Times editors, in phone calls and face-to-face meetings, that publication would damage national security and endanger lives, Risen said.

He said the officials were joined in that effort by Harman, one of a handful of congressional leaders who had been briefed on the program and were enlisted by the White House to contact the Times.

Harman, first elected in 1992, spent six years in Congress before leaving to run for governor of California and then regaining her congressional seat in 2000. She was a generally moderate Democrat who supported the war in Iraq. She resigned in 2011 to become president of the Woodrow Wilson International Institute of Scholars, a research organization that focuses on foreign policy.

In his story for the Intercept, Risen wrote that Philip Taubman, the newspaper’s Washington bureau chief, recently recalled the phone call he received from Harman. The call came after Taubman told an administration official that the Times needed to hear from leaders of congressional intelligence committees who knew about Stellar Wind.

Risen quoted Taubman as saying, “She told me that she and her colleagues, Democrat and Republican, strongly supported the NSA effort and requested that the (Times) not disclose it.”

In 2005, Risen said, Lichtblau, his coauthor, was covering a House Intelligence Committee hearing at which Harman called for tighter restrictions in federal information-gathering law to protect civil liberties. He said Lichtblau approached her in the hall and asked how she could square those comments with what she knew about the NSA program, and that Harman moved her aides out of hearing distance, grabbed him by the arm and reprimanded him for bringing up the subject.

“You should not be talking about that here,” the congresswoman told Lichtblau in a whisper, according to Risen’s article. “They (her aides) don’t even know about that.” And, she added, “The Times did the right thing by not publishing that story.”

The newspaper published the story later in 2005. The revelations angered civil-liberties advocates but produced no significant legal action, because the secrecy of the program made court challenges virtually impossible, except in the rare cases when the surveillance could be tied to specific criminal charges.

Contacted last week, Harman did not dispute the accuracy of the Intercept’s description of her actions. Asked whether she had any regrets, she did not answer directly, but said, “I strongly believe in a free press. But I think there are times when classified materials must be protected. I tried to act responsibly in a very tricky situation. In hindsight, I did not have all the facts.”

She did not elaborate on what she didn’t know at the time. But members of Congress learned later that the NSA had not been seeking warrants from a secret court, as required by law, before wiretapping calls between Americans and foreigners who were targeted for U.S. surveillance. The law that finally authorized the program in 2008 specified that the wiretaps must be aimed at foreigners and not at the Americans with whom they were in contact.

Risen said he also contacted House Minority Leader Nancy Pelosi, D-San Francisco, in late 2005, at the suggestion of Taubman, the Washington bureau chief, who wanted approval from Democratic leaders before running the story.

He said he went to see Pelosi, previously the top-ranking Democrat on the House Intelligence Committee, showed her the story, and asked if she would call Taubman. He said she replied, “The Times is a big institution. It can make its own decisions.”

Risen said she never said one way or the other whether the story was accurate.

Asked for comment on the incident, Pelosi’s office did not respond.

Bush himself got involved in December 2005, telling the Times’ publisher, Arthur Sulzberger, that there would be “blood on your hands” if the story was published, Risen said, quoting an editor who attended the meeting. But the newspaper published it later that month, shortly before Risen published a book, “State of War: The Secret History of the CIA and the Bush Administration,” which also described the NSA program.

Risen said in his article that the Times’ editors decided on publication after learning that the administration had considered going to court to stop them.

Risen and Lichtblau were awarded a Pulitzer Prize in 2006 for their reporting. While Bush administration officials criticized the publication, they never cited any resulting terrorist acts or damage to national security.

Bob Egelko is a San Francisco Chronicle staff writer. Email: begelko@sfchronicle.com Twitter: @egelko