A US judge has ordered Google to comply with FBI secret demands for customer data, despite earlier ruling the warrantless orders unconstitutional.

District court judge Susan Illston this week rejected the internet search giant's argument that so-called National Security Letters (NSLs) violated its constitutional rights. As such it ordered Google to hand over private information relating to US citizens to federal agents.

It comes despite Illston earlier ruling the letters unconstitutional in a separate case in March. In that case, brought by non-profit advocacy group the Electronic Frontier Foundation, the judge said that such demands violated the right to free speech.

She also ruled against gagging clauses attached to the demands that prevent the recipients of NSLs from disclosing the mere existence of an order.

"The court concludes that the nondisclosure provision violates the First Amendment … the government is therefore enjoined from issuing NSLs … or from enforcing the nondisclosure provision in this or any other case," Illston concluded in March.

The ruling followed a legal challenge brought by California telecommunications company Credo, the Guardian understands. A 90-day delay in the order coming into effect was put in place by the judge in anticipation of an appeal by the government.

But hopes from civil liberty groups that the ruling would blow a hole in the FBI's use of the secret demands for data have seemingly been dashed by this week's development

The ruling in the Google case was first disclosed by the Associated Press on Friday.

Illston's order omits any mention of Google. But the judge said "the petitioner" was involved in a similar case filed on April 22 in New York federal court.

Public records show that on that day, the federal government filed a "petition to enforce National Security Letter" against Google after the company declined to cooperate with government demands.

It was unclear from the judge's ruling what type of information the government sought to obtain with the letters. It was also unclear whom the government was targeting.

The judge put the Google ruling on hold until the 9th US Circuit Court of Appeals can decide the matter. Until then, she said, the company would have to comply with the letters unless it shows the FBI didn't follow proper procedures in making its demands for customer data in the 19 letters Google is challenging.

After receiving sworn statements from two top-ranking FBI officials, the judge said she was satisfied that 17 of the 19 letters were issued properly. She wanted more information on two other letters.

Google could appeal the decision. The company declined comment.

Kurt Opsah, an attorney with the Electronic Frontier Foundation, said: "We are disappointed that the same judge who declared these letters unconstitutional is now requiring compliance with them."

The letters, along with the recent seizure of reporters' phone records by the Obama administration, have prompted complaints of government overreach in regards to privacy violations in the name of national security.

Last year the FBI sent out more than 16,000 NSLs to companies relating to the private data – mainly financial, internet or phone records – of more than 7,000 Americans.