Washington -- California Sen. Dianne Feinstein has set up a clash with another powerful senior Democrat and drawn criticism from civil libertarians on the left and right for her defense of a national security program that collects Americans' telephone records.

The role is a familiar one for Feinstein, whose pro-law enforcement outlook has persisted from her days on a women's parole board and her tenure as San Francisco mayor. Now it's in full evidence in her leadership of the Senate Select Committee on Intelligence, which oversees the U.S. spy apparatus.

"I do not want to leave the United States in a position where we are open to another major attack because we can't ferret out who terrorists might be calling in this country to put it together," Feinstein said in an interview.

Her committee is drafting legislation to codify the phone records program, the existence of which was leaked in June by National Security Agency contractor Edward Snowden. The legislation would grant the agency explicit authority to gather records listing the numbers, duration and time of all U.S. telephone calls, but not their content.

Feinstein said the measure would increase privacy protections and congressional oversight of the program, but preserve activities she insisted are vital to heading off terrorist attacks.

Taking on Leahy

The legislation is a frontal challenge to Sen. Patrick Leahy, D-Vt., chairman of the Judiciary Committee, who is drafting a competing bill that would eliminate the NSA program. Feinstein is the Judiciary Committee's second-most-senior Democrat.

Feinstein describes the program as data collection. Leahy calls it domestic surveillance.

"People believe it's surveillance, but it's not," Feinstein said.

"Some may have a problem with the collection of data," she said, but "realistically, it's the only way we prevent an attack."

The clash arrives amid accusations that the agency eavesdropped on cell phone conversations of German Chancellor Angela Merkel, listened in on Mexican officials' phone calls and intercepted millions of calls in France - damaging the Obama administration's assertions that it is not misusing its spying capabilities.

'Fig leaf'

To critics, Feinstein is an apologist for the intelligence agencies.

Rep. James Sensenbrenner, R-Wis., an author of the 2001 Patriot Act that vastly expanded federal intelligence gathering powers, is sponsoring a House version of Leahy's bill. He has derided Feinstein's legislation as a "fig leaf" and questioned her committee's independence from intelligence agencies.

To her defenders, Feinstein is taking a courageous stand that has no political upside.

"She's always had the courage to break from the orthodoxy," said Stanford University political scientist Bruce Cain, even as he questioned whether Congress has asserted enough control over the intelligence agencies.

Feinstein has penned three opinion pieces in national newspapers defending the program and has frequently backed it in news conferences, often with ranking committee Republican Saxby Chambliss of Georgia at her side.

Behind the scenes, she is battling Leahy over which bill prevails.

"We'll see," Feinstein said. "There'll either be votes for it or there won't be."

Mixing party loyalties

A Judiciary Committee aide said any bill ultimately will need the support of both chairs to pass the Senate.

"There's definitely going to have to be a battle here between the two of them over who gets the base product," said Michelle Richardson, legislative counsel for the American Civil Liberties Union. Civil liberties groups have united behind Leahy.

The issue splits the parties. The program's opponents include liberal senators Ron Wyden, D-Ore., and Richard Blumenthal, D-Conn., and libertarian Rand Paul, R-Ky. Backing Feinstein are numerous Republicans and Democrats, among them former Intelligence Committee Chairman Jay Rockefeller, D-W.Va.

As leaks of NSA activities mount, public opinion is moving against Feinstein. The House last summer narrowly defeated an amendment to eliminate the program's funding.

Scooping up data

A key dispute is the Obama administration's contention that the Patriot Act permits the agency to collect data "relevant" to a terrorism investigation. Critics said the NSA has stretched the word beyond recognition by using a dragnet that collects data from innocent people as well as terrorist suspects, and then decides what is useful.

Feinstein has argued that the agency doesn't monitor the content of phone calls and that there are congressional and legal checks on its power.

She said the program is vital to "connect the dots" of terrorist activities, a key failing in the Sept. 11 attacks. She said the program has interrupted 54 "terrorist events," including 13 in the United States.

Katherine Stern, senior counsel for the Constitution Project, a libertarian group, noted that while the Supreme Court has not ruled on the program's constitutionality, it held last year that police exceeded their authority in tracking a suspect with a GPS unit. In doing so, the court said people have a reasonable expectation of privacy and warned that this applies to other electronic surveillance.

Bulk collection of phone records departs from "suspicion-based intelligence gathering," the ACLU's Richardson said. "Telephone numbers can reveal whether you're calling an attorney who specializes in divorce, or maybe one of those bankruptcy hot lines or a psychiatrist. It could reveal your intimate associations."

Feinstein would add safeguards and limit who could search the data, but "she's OK with collecting it all," Richardson said. "We and the rest of the privacy community are adamant that you shouldn't be collecting them in the first place."