Image copyright Getty Images Image caption Park Geun-hye (L) beat Moon Jae-in in the 2012 presidential election

South Korea's spy agency has admitted it tried to manipulate the result of the 2012 presidential election.

An internal inquiry found 30 teams worked for more than two years to try to ensure a conservative candidate won.

Park Geun-hye did beat liberal Moon Jae-in, but she is now facing trial for corruption and abuse of power and Mr Moon has replaced her.

Former spy chief Won Sei-hoon is currently on trial for a second time for trying to manipulate the election.

He was sentenced to three years in jail in 2015. The conviction was overturned on appeal and the new trial was ordered.

The in-house investigators at the National Intelligence Service (NIS) said the agency had hired internet experts to try to sway public opinion through social media postings.

Image copyright AFP Image caption Won Sei-hoon (centre) is on trial for a second time over the alleged manipulation

The operation was intended to ensure that outgoing President Lee Myung-bak was succeeded by another conservative.

Ms Park won by a narrow margin.

"The teams were charged with spreading pro-government opinions and suppressing anti-government views, branding them as attempts by pro-North Korean forces' to disturb state affairs," the investigating team said.

It also found that the NIS had tried to influence parliamentary elections in 2011 and 2012, as well as placing some opposition politicians under surveillance.

The new president has vowed to reform the NIS, and the new spy agency chief has pledged to end any involvement in domestic politics.

However, a spokesman for Ms Park's party said the inquiry itself showed the NIS continued to interfere.

The spokesman, Kang Hyo-sang, said: "The NIS says it will dissociate itself from politics but it is meddling in politics again by starting this probe."

Ms Park was charged in April with bribery, coercion, abuse of power and leaking state secrets.

She is accused of allowing close friend Choi Soon-sil to extort money from companies in return for political favours. She denies the charges.