In a small courtroom in Canberra last month, federal prosecutors finally began their controversial – or “scandalous” and “grotesque”, as some critics put it – case against a former spy and his lawyer for allegedly leaking details of a secret espionage operation targeting Timor-Leste.

But there were two noticeable absences: neither the spy, known as Witness K, nor his lawyer, Bernard Collaery, were in court.

“I have no one to charge,” observed the chief magistrate, Lorraine Walker. “Where are we going from here?”

It was a good question.

The pair is allegedly accused of revealing confidential information about an Australian operation to spy on Timor-Leste during sensitive negotiations about the division of a lucrative underwater oil and gas deposit.

“I presume the advice from the security agencies was that this leak was outrageous and someone had to be punished.”

Prosecutors have revealed no details about the alleged crime and the government intends to keep it that way. It wants to have the case heard under the National Security Information Act, which would keep almost all elements of it secret. This would allow the government to privately admit to an operation that, aired publicly, would deeply embarrass it and might raise questions about the legality of its actions.

When the case resumes on October 29, Witness K and Collaery will likely still be absent, as the lawyers attempt to resolve the extent to which the case should be kept confidential.

But the further wrangling over the case’s secrecy – and the government’s determination to press ahead with the prosecution – will only prolong this murky saga, which, with every step, seems to further shame the government and the country.

In Canberra, where the conduct of the intelligence community tends to receive bipartisan backing, questions about the prosecution have been raised mostly by the cross bench and the Greens.

Independent MP Andrew Wilkie, a former intelligence official, described the prosecution as “shameful”. He told The Saturday Paper he wants the Australian Federal Police – and possibly an independent commission of inquiry – to investigate the affair.

“We were not spying on another country because of our national security,” he says. “We were spying on the other party in a business negotiation.”

Despite a staunch effort by Attorney-General Christian Porter and his predecessor, George Brandis, to avoid publicity, a surprisingly rich account of the intelligence operation has emerged, and, as the case continues, further details have been leaking.

It was an operation that was brazen, though not highly risky, because the nation being targeted was poor and battle-scarred, and the country doing the spying was assumed to be its protector.

In July 2004, a small team of spies from the Australian Secret Intelligence Service (ASIS) planted a listening device in a ceiling cavity in the Palácio do Governo, the waterfront colonial-style building that housed the fledgling state’s cabinet. The device targeted the office used for private discussions by the Timorese negotiators. The ASIS spies were posing as Australian aid contractors.

In September and October 2004, four spies, including Witness K, who was acting director of technical operations, rented a room aboard the Central Maritime Hotel, a floating 133-room hotel anchored in Dili harbour. From this room, the team operated a listening station that had line-of-sight contact with the Palácio do Governo.

An agent acting for ASIS remained in the building and turned on the device whenever the Timorese negotiators went to the office to deliberate. The sounds were beamed to the hotel room, recorded and then couriered to the nearby Australian embassy, where they were transcribed and dispatched to Canberra for analysis.

The operation apparently succeeded: Australia walked away with a controversial deal that would give it half of the revenue from the project, even though the undersea deposit was much closer to Timor’s coastline.

In a new book published this month, called Island off the Coast of Asia, Clinton Fernandes, an international politics professor at the University of New South Wales and former Australian army intelligence officer, provides fresh details about the episode. He suggests that agents from Australia, or another country, may have used the intelligence to create divisions within the Timorese negotiating team.

“Knowing the other side’s bottom line allowed Australia to know where Timor-Leste was prepared to compromise, and which members of its team differed from the official line,” he writes.

“It could offer them incentives outside the gaze of their colleagues. An ASIS officer might not even make the initial approach; allied intelligence services sometimes fill in for one another to increase deniability.”

But the operation was eventually uncovered.

In 2013, Timor-Leste, which apparently learnt about the spying from Collaery, took action against Australia in the Permanent Court of Arbitration in The Hague, claiming the surveillance gave Australia an unfair advantage in negotiations and renders the original deal void.

After further talks, Australia switched tack and agreed to finally settle the maritime border dispute. Earlier this year, at the United Nations in New York, the two sides reached a deal granting Timor-Leste 70 per cent of the resources revenue, or 80 per cent if it was piped to Darwin for processing.

But this deal also allowed the Australian government to proceed with action against the two figures accused of revealing the operation: Witness K and Collaery.

Witness K was not exactly a whistleblower. He is believed to have hired Collaery because he was angry at having been dismissed from ASIS, which he thought was partly because of his frustration about the spying operation. He was apparently upset that two of the government figures who oversaw the operation – former foreign minister Alexander Downer and former secretary of the Department of Foreign Affairs and Trade Ashton Calvert – subsequently received, respectively, consultancy work and a board position with Woodside Petroleum, the firm that led the consortium due to exploit the deposit.

Despite the Timorese first complaining in late 2012 to Canberra about the espionage, proceedings against Collaery and Witness K were not started until May 30 this year.

The problem for the government was that it was still trying to resolve the border with Timor-Leste, and prosecuting the pair would effectively concede that the spying operation had occurred, which would jeopardise its negotiating position.

In response to recent queries by Rex Patrick, a Centre Alliance senator who formerly served in the navy, Christian Porter produced a time line that revealed the government’s steps in handling the case. The time line, obtained by ABC News, shows lengthy delays by the government before consenting to the prosecution.

Clinton Fernandes, who has watched the case closely, believes the government is pursuing the case to send a message to the intelligence community and to deter other spies from revealing more details about the operation.

“It is not just Witness K that was upset about that operation – there is an L and M and N,” he said.

“The government wants to warn off people in ASIS that might have disquiet about similar operations.”

Porter insists he was not motivated by vengeance or an attempt to delay the case.

“The decision in this matter was made within months of me taking on the portfolio and was based entirely on the request from the independent [Commonwealth Director of Public Prosecutions],” he told The Saturday Paper.

“External factors played no part in my consideration of the matter.”

Gareth Evans, who has served as both attorney-general and as foreign minister, the latter role including oversight of ASIS, said the decision to prosecute the pair was “shameless”. The government, he said, had been “spooked by the security establishment”.

“I presume the advice from the security agencies was that this leak was outrageous and someone had to be punished,” he told The Saturday Paper.

“But the attorney-general had complete discretion not to prosecute, and should have exercised it. The original spying on the East Timor cabinet room was just a grotesque misuse of ASIS’s capability by the Australian government. It was completely indefensible. No national interest return could justify the risk to bilateral relations and our international reputation if the bugging was discovered.”

He added: “Even more indefensible is the legal action against the so-called whistleblower and his lawyer. At every level this has just been intolerable overreach by the authorities.”

But Labor has its own questionable record when it comes to defending the interests of the Timorese. Indeed, Labor allegedly initiated surveillance of Collaery before it lost the 2013 election.

Mark Dreyfus, the shadow attorney-general, would not comment on Labor’s involvement. Asked whether Labor, if elected, would proceed with the case, he told The Saturday Paper that the decision to prosecute was made by the attorney-general and was “a matter for government”.

“It is important to let the judicial process take its course,” he said. “Labor is in favour of open and transparent court processes, as far as is permitted by national security concerns.”

For now, it seems the prosecution against Collaery and Witness K will continue, perhaps secretly. They are charged with disclosing confidential ASIS information under section 39 of the Intelligence Services Act. It is believed to be the first case of its kind: the penalty for their alleged crime is two years in prison, though the government has since changed the maximum to 10 years.