South Korea's Supreme Court on Thursday ordered a new trial for a former spy chief convicted of directing an online campaign to smear a main opposition candidate in the 2012 presidential election.

The top court granted Won Sei-hoon a new trial after rejecting a key piece of evidence that was used to convict him in the original trial, according a court statement.

Won has been serving a 3-year sentence for ordering his underlings to post online comments that praised the then-conservative ruling party candidate and current President Park Geun-hye and slandered her chief liberal rival Moon Jae-in.

The Supreme Court said files containing work-related writings and hundreds of Twitter accounts cannot be considered evidence in the case. Prosecutors had said the Twitter accounts were used to spread the negative comments about Moon.

The spy service has said its agents were only trying to counter North Korean cyberwarfare that included messages that praised the North and spread rumors about South Korean policies.

The court said in its statement that the text files could not be definitively linked to the smear campaign because similar files weren't found in other agents' email accounts and the files also contained personal information.

The court rejected Won's request for parole while awaiting a new trial. Court officials don't yet know when a new trial will begin.

Won was sent to prison in February when the Seoul High Court convicted him for violating an election law and another law banning the National Intelligence Service from engaging in local politics. Last year, he received a suspended prison term when a district court found he was guilty of violating only one of those two laws.

It's unclear if or how much the online campaigning helped Park win the 2012 election.

She hasn't been accused of any wrongdoing and took office in February 2013 for a single five-year term.

The spy service was founded by Park's father, Park Chung-hee, who ruled South Korea with an iron fist for 18 years until his 1979 assassination.

Under the elder Park's rule, spy agents detained, tortured and allegedly killed his political opponents. Similar abuses continued under his successors.

Earlier this week, NIS director Lee Byoung Ho told lawmakers that the agency bought hacking programs designed to intercept information from cellphones and computers from an Italian company in 2012, when it was headed by Won.

Lee said the purchase was only aimed at bolstering the agency's monitoring of North Korean agents, not South Koreans, but the revelation created a stir in South Korean media.