Several media companies had brought the lawsuit involving Telegram.
Consumer advocates in Spain, where there are several million Telegram users, criticized the measure as disproportionate.
However, Telegram was initially still accessible from Spain and, even if instituted, the ban could likely be circumvented with relative ease using protected network connections known as VPNs.
The court announced that Judge Santiago Pedraz had repeatedly requested administrative assistance from the authorities of the British Virgin Islands in the Caribbean, where Telegram is registered, to no avail.
Authorities there had not cooperated in clarifying the identity of the owners of Telegram accounts from which copyrighted content had been illegally distributed.
In the judge’s view, temporary blocking of the entire Telegram service was therefore “necessary, appropriate and proportionate,” according to the court.