PHNOM PENH (Reuters) - Sam Rainsy resigned from the presidency of Cambodia’s leading opposition party on Saturday, shortly after Prime Minister Hun Sen threatened legal changes that appeared to target his main opponent ahead of polls.

FILE PHOTO: Cambodian opposition leader Sam Rainsy delivers a speech to members of the Cambodia National Rescue Party (CNRP) at a hotel in metro Manila, Philippines June 29, 2016. REUTERS/Romeo Ranoco/File Photo

Hun Sen said this month that a law was being amended to stop anyone convicted of an offence from running for office for five years, effectively barring his main rival from elections.

Courts that critics say are influenced by Hun Sen have convicted Rainsy of a series of defamation charges, forcing the opposition leader into exile in France.

Hun Sen’s proposed changes to a 1998 law would also open up the possibility of political parties being dissolved if a leader is convicted of a serious crime.

Rainsy announced his surprise decision to step down from the leadership of the Cambodia National Rescue Party (CNRP) on his social media accounts on Saturday.

He said he was quitting for “personal reasons” and did not directly link his resignation to the proposed legal amendments.

“I resign as CNRP leader of the sake of the party,” he said on Twitter.

“In all circumstances, I cherish and uphold the CNRP’s ideals in my heart,” he added.

Cambodia holds local elections in June and a general election next year.

Opponents accuse Hun Sen of maneuvering to try to extend his rule. The former Khmer Rouge soldier has been at the top of Cambodian politics for more than three-decades, and has sought to tighten his grip on power since a newly unified opposition gained seats in 2013 elections.

Rainsy has not entered the country since 2015, and faces years in prison if he returns.

Lee Morgenbesser, a research fellow at Australia’s Griffith University, told Reuters that while it was not yet entirely clear what the movement meant for the opposition, it may have caught Hun Sen’s ruling Cambodian People’s Party (CPP) off-guard.

“For the CNRP, it certainly offers an opportunity to forge a more unified party ahead of key commune and national elections,” Morgenbesser said.

“The selflessness of Rainsy’s actions should certainly be applauded, but more time is required to gauge the full effect of his resignation on the opposition movement.”