WASHINGTON (AP) — Years before Edward Snowden sparked a public outcry with the disclosure that the National Security Agency had been secretly collecting American telephone records, some NSA executives voiced strong objections to the program, current and former intelligence officials say. The program exceeded the agency's mandate to focus on foreign spying and would do little to stop terror plots, the executives argued.

The 2009 dissent, led by a senior NSA official and embraced by others at the agency, prompted the Obama administration to consider, but ultimately abandon, a plan to stop gathering the records.

The secret internal debate has not been previously reported. The Senate on Tuesday rejected an administration proposal that would have curbed the program and left the records in the hands of telephone companies rather than the government. That would be an arrangement similar to the one the administration quietly rejected in 2009.

The now-retired NSA official, 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 its stated purpose — to hunt 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 he and his colleagues had been taught was 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 said 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. Until this year the circle had sometimes been expanded to a "third hop" — a process that could include analysis of millions of American phone calls. Obama in January restricted it to two hops, and required a court order each time the database is searched.

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 advance on 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.

By the end of 2009, Justice Department lawyers had concluded there was no way short of a change in law to make the program work while keeping the records in the hands of the companies, the former officials said. And key members of Congress had no interest in modifying a law that the public — and many lawmakers— did not realize was being used to justify bulk phone collection, the officials said.

The AP reported earlier this year that in 2011, when the bulk collection provision of the USA Patriot Act was up for re-authorization, the Senate intelligence committee secretly asked for options about modifying the phone records program, but decided it should not be changed. The former senior NSA official said his proposal was briefly resurrected and sent to Capitol Hill, only to be rejected again.

The NSA's collection of American phone records was the first and most controversial of the Snowden revelations to be revealed, at least for Americans, said Steven Aftergood, an intelligence expert at the Federation of American Scientists. The disclosure of the program would likely have caused much less of a stir had the records collection been stopped by the time Snowden leaked it, he said.

Since Snowden has cited government deception about the phone records collection as a key motivation, "It's possible that the entire Snowden leak might have been diverted" had the government curbed the program in 2009 or 2011, Aftergood said.

"This program was so at variance with the official position of the U.S. government," he said, "that it inspired its own unauthorized disclosure."