Image copyright AP

Yahoo said the US government threatened to fine it $250,000 a day if the search giant failed to hand over user data.

According to court documents, the National Security Agency (NSA) had demanded that Yahoo comply with new surveillance rules, something the company said was unconstitutional.

Yahoo failed in a court challenge on the constitutionality of the order.

But the details emerged on Thursday when a federal judge ordered the unsealing of some material about the case.

Yahoo's general counsel Ron Bell said publication of the material was "an important win for transparency".

Yahoo said that the government amended a law to demand user information from online services, prompting a court challenge. Former NSA contractor Edward Snowden disclosed the programme last year.

But the court documents reveal that the battle over surveillance between technology firms and the US government stretched back years before the Snowden revelations.

The new material about the case, first reported by the Washington Post, underscores "how we had to fight every step of the way to challenge the US government's surveillance efforts',' Mr Bell added.

"At one point, the US government threatened the imposition of $250,000 in fines per day if we refused to comply," he said.

About 1,500 pages of previously classified documents were unsealed by a federal court.