WASHINGTON (Reuters) - A U.S. court has ruled that the eavesdropping National Security Agency can temporarily resume its bulk collection of Americans’ telephone records, according to documents made public on Tuesday.

A National Security Agency (NSA) data gathering facility is seen in Bluffdale, about 25 miles (40 km) south of Salt Lake City, Utah May 18, 2015. REUTERS/Jim Urquhart

The controversial program, exposed by former NSA contractor Edward Snowden, was rocked in May by an appeals court ruling that the USA Patriot Act had never authorized the NSA to collect Americans’ phone records in bulk.

A new law, called the Freedom Act, which substantially reformed and narrowed the bulk phone data program, was signed by U.S. President Barack Obama a day after the existing program lapsed on June 1.

The Freedom Act also allowed the existing surveillance program to continue for a six-month transition period, but it remained in legal limbo pending Monday’s ruling by a judge of the Foreign Intelligence Surveillance Court.

“In passing the USA Freedom Act, Congress clearly intended to end bulk data collection ... But what it took away with one hand, it gave back - for a limited time - with another,” wrote Michael Mosman, a judge on the surveillance court.

In his ruling, first reported by the New York Times, Mosman rejected the May ruling by the 2nd U.S. Circuit Court of Appeals in Manhattan that the Patriot Act had never authorized the NSA to collect Americans’ phone records in bulk.

“Second Circuit rulings are not binding on the F.I.S.C. and this court respectfully disagrees with that court’s analysis, especially in view of the intervening enactment of the U.S.A. Freedom Act,” he wrote.

The U.S. Justice Department welcomed the decision.

“We agree with the Court’s conclusion that the program is lawful, and that in passing the USA Freedom Act, Congress provided for a 180 day transition period for the government to continue the existing collection program until the new mechanism of obtaining call detail records is implemented,” said Justice Department spokesman Wyn Hornbuckle.

The NSA program collects and analyzes data about Americans’ phone calls, such as the number dialed, and the time and length of the call, but not the calls’ actual content.

The Freedom Act requires companies such as Verizon Communications Inc VZ.N and AT&T Inc T.N, to collect and store telephone records the same way that they do now for billing purposes.

But instead of routinely feeding U.S. intelligence agencies such data, the companies will be required to turn it over only in response to a government request approved by the FISC.