East Timor's most senior leaders have accused Australia of committing a crime and acting immorally after a spying scandal that rocked the relationship between the two countries.

A history of treaties in the Timor Sea In 1989 Australia and Indonesia signed the Timor Gap Treaty when East Timor was still under Indonesian occupation.

In 1989 Australia and Indonesia signed the Timor Gap Treaty when East Timor was still under Indonesian occupation. East Timor was left with no permanent maritime border and Indonesia and Australia got to share the wealth in what was known as the Timor Gap.

East Timor was left with no permanent maritime border and Indonesia and Australia got to share the wealth in what was known as the Timor Gap. In 2002 East Timor gained independence and the Timor Sea Treaty was signed, but no permanent maritime border was negotiated.

In 2002 East Timor gained independence and the Timor Sea Treaty was signed, but no permanent maritime border was negotiated. East Timor has long argued the border should sit halfway between it and Australia, placing most of the Greater Sunrise oil and gas field in their territory.

East Timor has long argued the border should sit halfway between it and Australia, placing most of the Greater Sunrise oil and gas field in their territory. In 2004 East Timor started negotiating with Australia again about the border.

In 2004 East Timor started negotiating with Australia again about the border. In 2006 the CMATS treaty was signed, but no permanent border was set, and instead it ruled that revenue from the Greater Sunrise oil and gas field would be split evenly between the two countries.

The ABC's Lateline has revealed new details about the bugging of an East Timor cabinet office during negotiations over an oil and gas treaty worth an estimated $40 billion.

In a diplomatic bungling of the highest order, after the scandal came to light in 2012, the Gillard government sent a representative to Dili to deal with the fallout. But former East Timorese president Xanana Gusmao told Lateline that person had been directly involved in the operation, causing further offence to East Timor.

Lateline was also told there was concern in senior Australian intelligence circles that the operation was a misuse of intelligence resources.

East Timor's prime minister Rui Maria de Araujo called it a moral crime.

"Having that as an advantage for you to negotiate something that is a matter of death and life for a small country, I think it's - at least morally - it's a crime," he said.

Mr Gusmao said he considered it a criminal act.

"Australia would not allow it. Under the Security Act it will be a criminal act? No? For us we believe it should be considered like this," he said.

East Timor's resources minister Alfredo Pires said Australia would not stand for such behaviour from another state.

"If I was to do a similar thing in Canberra I think I would be behind bars for a long time," he said.

Australian spies bugged government building

It all began in 2004, when under the guise of an aid project to help renovate the Palace of Government in Dili, spies from Australia's foreign intelligence service ASIS snuck in and installed listening devices.

They were targeting East Timor's prime minister at the time, Mari Alkatiri, and his negotiating team, who were in talks with the Australian government over a treaty dealing with oil and gas deposits in the Timor Sea.

The Greater Sunrise oil and gas field in the Timor Sea is worth an estimated $40 billion and the treaty would map out how it was divided between East Timor and Australia.

East Timor is one of the poorest nations in the region; 50 per cent of children under five are malnourished and only half the homes have electricity.

Australia is East Timor's richest neighbour and the bugging operation gave the government the upper hand in the multi-billion-dollar talks.

Mr Alkatiri has described it as a crime.

"I have no doubt about this, even in terms of international law it's a crime," he said.

Half the children under five in East Timor are malnourished. ( ABC: Brant Cumming )

When the operation came to light in 2012, Mr Gusmao, who was then prime minister, sent a letter to his Australian counterpart Julia Gillard, seeking an explanation.

Her response shocked him.

Lateline understands that Ms Gillard denied the substance of the complaint and sent a representative to meet Mr Gusmao, but that person had played a key role in the undercover operation.

"I was, what? Sending me the person that I know was participating in this? Well!" Mr Gusmao said.

Lateline understands the representative's role in the operation included delivering transcripts of the bugged conversations from the embassy in Dili straight into the hands of Australia's negotiating team.

Lateline cannot name that person because of strict provisions in the Intelligence Services Act.

Bernard Collaery was East Timor's legal adviser at the time and said it was almost comical if it had not been such a tragic affront to the young nation.

Space to play or pause, M to mute, left and right arrows to seek, up and down arrows for volume. Watch Duration: 11 minutes 45 seconds 11 m Interview with Peter Galbraith, negotiator for East Timor during treaty talks

"It deeply aggrieved Prime Minister Gusmao," he said.

"His reaction was he was grieving over the knowledge that someone he thought he trusted had been involved.

"Then to have Prime Minister Gillard send that very person to Timor as it were to discuss the matter to try and resolve it as Prime Minister Gillard put in her letter was very, very worrying.

"It meant that the Prime Minister of a modern democracy on Timor Leste's doorstep did not know what her intelligence service was doing."

Ms Gillard declined to comment.

Witness K tells of anger among spies

Appalled by how the Gillard government had handled the matter, in 2013 East Timor notified Australia that it was taking the case to the Permanent Court of Arbitration in The Hague.

The East Timorese had an ace up their sleeves.

Mr Collaery happened to have as a client the agent who ran the bugging operation in 2004.

He became known as Witness K.

Witness K is a former senior ASIS officer. Lateline cannot identify him without risking prosecution.

Witness K and other senior ASIS officers were concerned intelligence resources had been misused in the bugging of the East Timorese government.

Only half the homes in East Timor have electricity. ( ABC: Brant Cumming )

The Dili bugging operation began 18 months after the Bali bombing terrorist attacks that killed 202 people, including 88 Australians.

ASIS was at the time focused on preventing further terrorist attacks in the region.

Mr Collaery said ASIS operatives were angered when instead they were given directions to spy on impoverished East Timor.

"When you have such dedicated veterans involved who might see the relative priorities of following up on the Bali bombing, the Marriot Hotel issues, and find themselves taken off duties to bug this poverty stricken state's cabinet room so a trade deal can get over the line, if you were part of that, staff might wonder about priorities," he said.

Mr Collaery said it was also a moral issue for Witness K.

"It was a squalid operation and indeed I recall in my instructions mention being made of [East Timor's] infant mortality rate," he said.

"So this was a morally based grievance."

In 2013, Witness K was all set to give evidence in the Permanent Court of Arbitration when ASIO raided his home and seized his passport. To this day he is unable to leave the country.

Abbott accused of shrugging off scandal

In East Timor, anger has only grown over Australia's refusal to acknowledge the bugging operation.

Mr Gusmao accused former prime minister Tony Abbott of shrugging off the scandal when they met in China last year.

"I was with [former East Timor prime minister] Mr Mari Alkatiri in Boao in a conference in China and we met the former prime minister Tony Abbott," he said.

"Mr Mari said to him 'look I'm very, very sad knowing that you spy on us, on our meetings and conversations'.

"And you know what Mr Tony Abbott said? 'Don't worry my friend, [the] Chinese are listening to us.'"

East Timor's then-PM Xanana Gusmao talks to the media in 2008 ( Gary Ramage/Pool: Reuters )

East Timor is now recommencing its action against Australia in the Permanent Court of Arbitration.

For the East Timorese, it will be crucial that Witness K's passport is returned so he can travel to The Hague to testify in the case.

Mr Collaery said he had written to ASIO's new director-general Duncan Lewis and said he was optimistic that he would get an answer in the next week.

"Mr Lewis has responded quite properly in my view, putting the issue back to the relevant department, the Department of Foreign Affairs. It issues passports," he said.

"I've gained no information from Mr Lewis that there's a national security objection to K giving evidence."