The National Court, which handles major criminal cases, slapped the order on Prime Minister Mariano Rajoy's conservative party, the November 30 ruling said.
The PP, in power since December 2011 and headed by Rajoy for the past 13 years, is accused of having destroyed the hard drives of laptops belonging to its longtime former treasurer Luis Barcenas at its Madrid headquarters before
investigators had access to them. The hard drives may have had information about an alleged illegal funding racket within the PP.
The court also ordered the party's current treasurer to go on trial along with its former IT specialist and a party lawyer for damaging computers and concealing evidence.
“With the erasure of the data an important investigation was prevented from being carried out in a case of undeniable importance,” the judge wrote in the ruling.
Barcenas himself filed a criminal complaint for the destruction of his laptops in 2016 but later withdrew it.
Rajoy in July testified as a witness in a major graft trial involving members of his party.
Barcenas is a key suspect in this so-called Gurtel trial revolving around a vast kickbacks scheme that allegedly helped finance the PP, which has been weakened by repeated accusations of graft.
Rajoy was the first acting prime minister to appear in court as a witness since Spain's transition to democracy following dictator Francisco Franco's death in 1975.
Barcenas, who resigned as PP treasurer in 2009, is suspected of having hidden €48 million in Swiss bank accounts. He has said that he is innocent and that the Swiss bank accounts were held on behalf of investors.