WASHINGTON — She fought so hard to outlaw assault weapons that the National Rifle Association deemed her efforts tantamount to proposing the largest gun ban in American history. Well before the Supreme Court took up same-sex marriage, she sponsored a bill to repeal the Defense of Marriage Act. And she urged President George W. Bush, and later President Obama, to shut down the prison camp at Guantánamo Bay, Cuba.

But Senator Dianne Feinstein — California Democrat and liberal lioness — has taken on a role that is leaving many of her allies on the left dismayed: as perhaps the most forthright and unapologetic Congressional defender of the National Security Agency’s surveillance programs.

“I think it’s an act of treason,” she said of the leaks by Edward J. Snowden, the N.S.A. contractor who revealed classified details about the programs, even as many liberals were hailing him as a whistle-blower. She has praised James R. Clapper Jr., the director of national intelligence, who has been accused of lying to the Senate about the scope of the programs, as an honest and direct man.