NUSA DUA, Indonesia - Indonesia and Australia on Thursday signed an agreement aimed at drawing a line under a damaging espionage row and paving the way for the resumption of full cooperation on issues such as defence.
Ties between the neighbours sank to their lowest point in years in November after reports that Australian spies tried to tap the phones of President Susilo Bambang Yudhoyono and his inner circle.
Jakarta recalled its ambassador from Canberra and suspended cooperation in several areas over the incident, including efforts to stop people-smuggling boats reaching Australia.
Yudhoyono called for a code of conduct to govern behaviour and, after months of talks on the issue, Australian Foreign Minister Julie Bishop and her Indonesian counterpart Marty Natalegawa on Thursday signed an agreement.
With Yudhoyono looking on, the pair inked the deal, named the "Joint Understanding on a Code of Conduct between the Republic of Indonesia and Australia", at a ceremony on the Indonesian resort island of Bali.
In the agreement, Indonesia and Australia pledge to not use their intelligence agencies to harm one another and to increase cooperation at a time fears are growing about the threat posed by home-grown Islamic militants returning from Middle East conflicts.
"We are back to where we should have been in terms of Indonesia-Australia relations," Natalegawa said, adding that he believed cooperation would be "even more enhanced in the future in front of us".
Bishop said: "Despite some recent challenges in our relationship - as there can be between neighbours, even strategic partners as close as Australia and Indonesia - we have proven that our two countries can keep working together across the board." She added the agreement was "the most effective way to defeat those who would do harm to the people of Australia and Indonesia".
Both countries have expressed alarm that home-grown extremists are heading in increasing numbers to fight with violent groups such as the Islamic State overseas, and have stepped up counter terrorism efforts.
Yudhoyono said he hoped relations would be strengthened by the accord: "I am hoping, personally, that we could go back to our strong relations and effective cooperation."
Allegations that Australian spies tried to tap the phones of Yudhoyono, his wife and several top officials in 2009 sparked one of the worst diplomatic crises between the two strategic allies in years.
Reports at the time said that Australia's electronic intelligence agency tracked Yudhoyono's activity on his mobile phone for 15 days in August 2009, when Labor's Kevin Rudd was prime minister.
The list of tracking targets also included his wife Ani, the foreign affairs spokesman, the security minister and the information minister.
Jakarta responded furiously to the reports, which were based on documents leaked by US intelligence fugitive Edward Snowden, by suspending bilateral cooperation in key areas.
Ties were further strained by Australia's policy of pushing people-smuggling boats carrying asylum-seekers back to Indonesia.
Indonesia and Australia are close strategic and trading partners and have traditionally worked together in many areas, including on anti-terrorism initiatives and on the sensitive issue of would-be refugees.