The U.S. National Security Agency is expected to end its daily vacuuming of millions of Americans' phone records on Sunday and replace the practice with more tightly targeted surveillance methods. (Reuters)

The National Security Agency on Sunday will end its mass collection of data about Americans’ phone calls under the Patriot Act, 2 1/2 years after a leak by former NSA contractor Edward Snowden forced the government to confirm its existence.

The halt was ordered by Congress, which in June passed the USA Freedom Act to ban the controversial collection of information known as metadata. That data includes the dates and durations of phone calls and logs of call times, but not content.

Under the new law, the NSA must obtain a court order to receive records about phone numbers suspected of belonging to terrorist suspects.

The program began in secret 14 years ago under the authority of President George W. Bush, and for years, the government kept it mostly secret. But in the summer of 2013, it was forced to acknowledge the program after Snowden’s leak of a court order showing that the agency was gathering from a Verizon phone company “all call detail records” of its customers on a daily basis.

The revelation touched off a contentious two-year debate about the proper scope of government surveillance and several lawsuits challenging the program

In January 2014, President Obama called on Congress to come up with a way to end the bulk collection of phone metadata, saying that although he had seen no evidence of abuse by the NSA, the program lessened trust in the government.

Although the phone metadata program had been placed under court supervision in 2006, that action, too, was secret. The public — and many lawmakers, apparently — did not know the vast scope of the collection or the legal authority on which it was based.

Following the leak, the government revealed that it had interpreted Section 215 of the Patriot Act in a way that allowed such bulk collection. The reasoning essentially held that all records were needed in the event that one day some of them might prove useful in foiling a terrorist plot.

Under the USA Freedom Act, the government must report annually to Congress and the public, among other items, the total number of orders issued under the new authority and the number of targets of such orders.

The NSA has requested access to historical phone metadata until Feb. 29, limited to technical personnel and only for the purpose of verifying that the new system is working as intended, according to the Office of the Director of National Intelligence (ODNI). The Foreign Intelligence Surveillance Court is considering the request.

Separately, the ODNI said, the NSA remains under a legal obligation to preserve the phone metadata it has collected until civil litigation regarding the program is resolved or the relevant courts relieve the NSA of such obligations. The NSA and the Justice Department have declined to state whether that means they will preserve all the records or just those that are relevant to the litigation.

The phone records preserved solely for legal obligations will not be used or accessed for any other purpose, officials said, and the NSA will destroy them as soon as possible after the legal obligations end, the ODNI said.