The federal government's collection of bulk data from the telephone calls of virtually every American will stop at midnight Saturday, ending a raging controversy that began with disclosures about the secret program by Edward Snowden.

Beginning Sunday, if the government wants to check on a specific phone number in a potential terrorism case, a request must be made to the relevant telephone company for a check of its own data. The government will no longer retain the information.

President Obama said in January that the bulk data collection would end, and Congress in June formally banned it but allowed for a six-month transition period that ends Saturday.

Related: Obama Signs Limits on NSA Surveillance Powers

Under the program, the government collected information about calls made, including their duration and the phone numbers involved. But the content of the calls was not monitored, recorded, or collected.

A statement from the Office of the Director of National Intelligence defended the revised program.

"There is still a need to be able to identify communications between terrorists abroad and individuals with whom they are in contact in the United States," the statement said.

Under the revision, the government will present a specific phone number or cell phone identifier to the phone companies to seek the relevant call data. Except in emergencies, the records can be obtained only with an individual order from a special federal intelligence court.

For now, the National Security Agency, which ran the massive government data collection program, will retain access to the data it collected before the program was ended.

The NSA says it will check that database only to test the new program and to conform to court orders in civil cases challenging the program's constitutionality.