A former Australian spy announced a surprise guilty plea Tuesday for exposing an alleged 2004 bugging operation against East Timor officials, after years of fighting the charges.

Lawyers for the former agent, known only as “Witness K”, told a Canberra court he would plead guilty to blowing the whistle on the spying operation against the newly independent government of East Timor, national broadcaster ABC said.

The man’s lawyer, Bernard Collaery, who was charged with conspiring to violate the secrecy act with his client, said he would continue to fight the charges.

The case against Witness K and Collaery became public a year ago, when they were charged with breaching the Intelligence Services Act for divulging details of an alleged operation to bug East Timor’s cabinet rooms during negotiations over an oil and gas treaty and maritime boundary.

The protracted row over the maritime border — with billions of dollars in offshore gas revenue at stake — was finally resolved in March 2018 and Australia’s parliament ratified the deal just last week.

East Timor, which gained independence from Indonesian occupation in 2002, is impoverished and depends heavily on oil and gas exports.

In 2006, it signed a maritime treaty with Australia which covered the vast Greater Sunrise gas field between the two nations, which has an estimated worth of between US$40-50 billion.

But East Timor’s government in Dili then accused Australia of spying for commercial advantage and demanded the treaty be ripped up.

Witness K was key for East Timor in the case, which Dili finally dropped in June 2015 after Australia returned sensitive documents, leading to the dispute’s eventual resolution.

Australia’s hardline stance in the dispute with its impoverished neighbour damaged the country’s reputation, and Collaery suggested the charges against him and his client were politically motivated.

“This is a very determined push to hide dirty political linen… in the guise now of national security imperatives,” Collaery, a former attorney-general for the Australian Capital Territory which includes Canberra, said outside court.

He expressed sympathy for Witness K’s decision to plead guilty rather than continue the six-year fight against the charges.

“I have great empathy for Witness K and the struggle that Witness K has gone through spiritually, mentally and physically,” he said.

The conservative Australian government’s handling of whistleblowers and secrecy has been in the spotlight in recent weeks after federal police raided the headquarters of the ABC and the Canberra home of a prominent journalist over news reports linked to leaked documents.

Unlike most democracies, Australia has no formal protections for freedom of the press or for whistleblowers who expose alleged government wrongdoing.