Dissenters within the National Security Agency, led by a senior agency executive, warned in 2009 that the program to secretly collect American phone records wasn't providing enough intelligence to justify the backlash it would cause if revealed, current and former intelligence officials say.

The NSA took the concerns seriously, and many senior officials shared them. But after an internal debate that has not been previously reported, NSA leaders, White House officials and key lawmakers opted to continue the collection and storage of American calling records, a domestic surveillance program without parallel in the agency's recent history.

The warnings proved prophetic last year after the calling records program was made public in the first and most significant leak by Edward Snowden, a former NSA systems administrator who cited the government's deception about the program as one of his chief motivations for turning over classified documents to journalists. Many Americans were shocked and dismayed to learn that an intelligence agency collects and stores all their landline calling records.

In response, President Barack Obama is now trying to stop the NSA collection but preserve the agency's ability to search the records in the hands of the telephone companies — an arrangement similar to the one the administration quietly rejected in 2009. But his plan, drawing opposition from most Republicans, fell two votes short of advancing in the Senate on Tuesday.

A now-retired NSA senior executive, who was a longtime code-breaker who rose to top management, had just learned in 2009 about the top secret program that was created shortly after the Sept. 11, 2001, attacks. He says he argued to then-NSA Director Keith Alexander that storing the calling records of nearly every American fundamentally changed the character of the agency, which is supposed to eavesdrop on foreigners, not Americans.

Alexander politely disagreed, the former official told The Associated Press.

The former official, who spoke only on condition of anonymity because he didn't have permission to discuss a classified matter, said he knows of no evidence the program was used for anything other than hunting for terrorism plots in the U.S. But he said he and others made the case that the collection of American records in bulk crossed a line that had been sacrosanct.

He said he also warned of a scandal if it should be disclosed that the NSA was storing records of private calls by Americans — to psychiatrists, lovers and suicide hotlines, among other contacts.

Alexander, who led the NSA from 2005 until he retired last year, did not dispute the former official's account, though he said he disagreed that the program was improper.

"An individual did bring us these questions, and he had some great points," Alexander told the AP. "I asked the technical folks, including him, to look at it."

By 2009, several former officials said, concern about the "215 program," so-called for the authorizing provision of the USA Patriot Act, had grown inside NSA's Fort Meade, Maryland, headquarters to the point that the program's intelligence value was being questioned. That was partly true because, for technical and other reasons, the NSA was not capturing most mobile calling records, which were an increasing share of the domestic calling universe, the former officials said.

The dissent prompted NSA leaders to examine whether the agency could stop gathering and storing domestic landline calling records and instead access the records as needed from the telephone companies, Alexander said. The NSA consulted with the Justice Department, Congress and the White House, newly occupied by President Barack Obama.

But the government ultimately decided against changing what most officials still view as a necessary bulwark against domestic terror plots, Alexander and other former officials said. The program collects and stores so-called metadata on every landline phone call made in America — the phone number called from, the phone number called and the duration of the call. Some estimates have estimated the program collects records on up to 3 billion calls a day.

In 2006, the program came under the supervision of the Foreign Intelligence Surveillance Court. The agency, which continues to obtain the records from telephone companies under a court order, says it searches them only for connections to phone numbers suspected of association with overseas terror groups.

Under a process known as "contact chaining," analysts examine the numbers that had been in contact with the "dirty number" and then the numbers in contact with those. Sometimes the circle is expanded to a "third hop" — a process that could include analysis of millions of American phone calls. Only 30 intelligence employees are permitted to access the database, officials have said, and it is done about 300 times a year.

Current and former intelligence officials disagree about whether the phone record searching has been important in stopping terror attacks. The U.S. has been able to point to a single terrorism case that came to light exclusively through a domestic phone records match — that of an Anaheim, California, cab driver who was sentenced earlier this year to six years in prison for sending money to Somalia's al-Qaida affiliate.

To address their concerns, the former senior official and other NSA dissenters in 2009 came up with a plan that tracks closely with the Obama proposal that the Senate failed to pass Tuesday. The officials wanted the NSA to stop collecting the records, and instead fashion a system for the agency to quickly send queries to the telephone companies as needed, letting the companies store the records as they are required to do under telecommunications rules.

In a departure from the bill that failed Tuesday, however, they wanted to require the companies to provide the metadata in a standardized manner, to allow speedy processing and analysis in cases of an imminent terror plot. The lack of such a provision was among the reasons many Republicans and former intelligence officials said they opposed the 2014 legislation.