Australia clinched a security deal with Papua New Guinea on Thursday, bolstering ties to a key Pacific neighbour that has been courted persistently by China.
Canberra pushed for a more substantive treaty earlier this year, but Papua New Guinea baulked because leaders feared it undermined the country's "sovereign rights".
The salvaged agreement focuses on Papua New Guinea's domestic security, as stretched police struggle to stamp out arms trafficking, drug smuggling and tribal violence.
Papua New Guinea Prime Minister James Marape said the deal covered a "broad spectrum of security", including policing and support for the country's judiciary system.
Australian Premier Anthony Albanese said it would promote "regional stability" in the Pacific.
Papua New Guinea granted the United States "unimpeded" access to key naval bases, ports and airfields under a deal hammered out in May this year.
But there was a swift political backlash, with opponents concerned the former British colony was yielding too much influence to foreign powers.
Australian Strategic Policy Institute analyst Euan Graham said the backlash had ultimately damaged Canberra's efforts.
"That's why it has taken until now, because of the political capital Marape used on the American agreement," he told AFP.
"He couldn't do a deal with Australia at the same time."
Marape and Albanese said earlier this year that they were putting the finishing touches on a major bilateral security treaty.
But that agreement -- which they had hoped to sign in June -- started unravelling in the closing stages of negotiations.
By July, Marape was voicing concerns that unspecified clauses encroached on his country's "sovereign rights".
Thursday's revised agreement includes more resources for Papua New Guinea's police, assistance for the country's judges, and measures to tackle gender-based violence.
It also covers climate change, cyber security and disaster relief.
Perched less than 200 kilometres (125 miles) from Australia's northernmost border, Papua New Guinea is the largest and most populous state in Melanesia.
It is blessed with vast deposits of gas, gold, and minerals -- and peers over some of the Pacific region's busiest shipping lanes.
"Because of its size, population, and geography it's always going to be a logical anchor point for a Pacific policy," said Graham.
The United States and ally Australia have been on a diplomatic blitz to shore up their relationships in the South Pacific.
They were jolted into action after Solomon Islands -- Papua New Guinea's eastern neighbour -- signed a secretive security pact with Beijing in April 2022.
Marape stressed on Thursday that his country was not picking sides.
"Our major foreign policy remains friends to all and enemies to none.
"It's never at the expense of relationships elsewhere,"
China has been on its own Papua New Guinea charm offensive, pouring money into trade, real estate and infrastructure projects.
But Graham said that, so far, it had struggled to convert these links into anything of major military significance.
"China's economic links to Papua New Guinea's elite are now very deep, that's not going to disappear overnight," he said.
"But in defence terms, the penetration that China has made in Papua New Guinea is fairly shallow.
"They have been casting around for ports and airfield investments, but I think those are still quite speculative."