A federal judge in San Francisco on Monday stopped the destruction of millions of telephone records collected by the National Security Agency more than five years ago.

U.S. District Judge Jeffrey White, who is overseeing an invasion-of-privacy lawsuit against the agency, issued a nationwide order to safeguard evidence until March 19, when he will hold a hearing on extending the deadline further.

The secret federal court that approved the agency’s surveillance has required that documents be purged after five years for privacy reasons. On Friday, the Foreign Intelligence Surveillance Court denied the federal government’s request to keep the records for the sake of pending lawsuits.

The NSA, which has acknowledged obtaining phone numbers and other information on all U.S. calls, was prepared on Tuesday to destroy all records collected more than five years ago, according to court documents.

Mr. White said he was enforcing an order he had issued in an earlier NSA surveillance case that halted evidence from being destroyed.

Mr. White wrote that “the Court would be unable to afford effective relief once the records are destroyed” and before he decided if their collection was legal. The plaintiffs in the lawsuits include civil rights, environmental and religious groups as well as gun organizations and marijuana advocates.

The NSA started collecting domestic phone call records in the wake of the Sept. 11, 2001, terrorist attacks. Since 2006, the agency has obtained warrants from the Foreign Intelligence Surveillance Court.

The White House referred questions on the NSA records to the Justice Department, which did not immediately respond to a request for comment.

More In: World | International | News