HONG KONG (Reuters) - Hong Kong’s legal chief, whose watch was marked by instances of perceived interference by China in the city’s rule of law, stepped down on Friday, more than four years before the end of his term.

FILE PHOTO: Hong Kong Chief Executive Carrie Lam and Secretary for Justice Rimsky Yuen attend a news conference on arrangements at West Kowloon Terminus for the Guangzhou-Shenzhen-Hong Kong Express Rail Link in Hong Kong, China December 27, 2017. REUTERS/Tyrone Siu

An independent legal system sits at the core of the wide-ranging autonomy promised after Britain handed its former colony back to China in 1997 under a “one country, two systems” formula that guarantees it freedoms not enjoyed on the mainland.

Hong Kong leader Carrie Lam said Justice Secretary Rimsky Yuen had resigned for personal reasons, after starting his second five-year term in July.

“He has been a pillar of strength in upholding the rule of law in Hong Kong,” Lam said.

But Yuen’s time in office was punctuated by several controversies, including two rare protests by hundreds of lawyers.

Yuen, 53, was one of the key officials tasked with promoting a contentious political reform package in 2014, which later helped trigger the months-long “Umbrella Movement” street protests demanding, in vain, full democracy for the city.

He was targeted by demonstrators after reports last year that he had overruled several senior public prosecutors to seek jail terms for three democrats involved in those protests, including Joshua Wong, the bespectacled young activist who became the public face of the demonstrations.

He was also criticized for pushing through an immigration arrangement that would allow Chinese officials to implement mainland laws inside a downtown high-speed railway station.

Yuen and Communist Party officials in Beijing argued that parts of the station would be legally regarded as “mainland Chinese territory”, so the city’s mini-constitution, the Basic Law, which explicitly says national laws don’t apply in Hong Kong, would not be applicable.

The Hong Kong Bar Association called Beijing’s move “the most retrograde step to date in the implementation of the Basic Law”.

On each occasion, “the ultimate decision was made in accordance with the law”, Yuen said on Friday, even though some people might not like the results.

Yuen also reportedly tried to dissuade Beijing from interfering in a court case against pro-independence lawmakers last year, and spoke openly about how “matters that can be properly handled within Hong Kong’s legal or judicial system should be left to be dealt with at the Hong Kong level as much as possible”.

The Chinese parliament ultimately issued an interpretation of the law, pre-empting the judge’s decision, effectively barring the lawmakers from their posts. That prompted 2,000 lawyers to march in protest against what they said was the most blatant interference in the city’s judicial independence.

Incoming Justice Secretary Teresa Cheng, 59, said her “prime mission” would be to uphold the rule of law and that she would pursue criminal prosecutions “without any interference”.