UNITED NATIONS (AP) — Australia and East Timor signed a historic treaty drawing their maritime boundary Tuesday, ending years of bitter wrangling over billions of dollars of oil and gas riches lying beneath the Timor Sea and opening a new chapter in relations.

The agreement was doubly historic because it also marked the successful conclusion of the first-ever negotiations to settle maritime differences under the U.N. Convention on the Law of the Sea — a process that Secretary-General Antonio Guterres urged other countries to use to peacefully resolve such disagreements.

Before a crowd of cameras, diplomats and officials, two copies of the treaty were signed by Australia's foreign minister, Julie Bishop, and East Timor's minister for delimitation of borders, Hermenegildo Augusto Cabral Pereira. The chairman of the independent Conciliation Commission that led negotiations, Danish Ambassador Peter Taksoe-Jensen, then signed as a witness.

"It is a landmark event for our two nations, but also for international law," Bishop said. "Both our governments have deemed this to be a just and equitable outcome."

Pereira agreed, saying: "Today is indeed a momentous day that will be recorded in East Timor's history and be remembered and celebrated. ... With the signing of this treaty today, we write a new chapter in the friendship between our two countries."

For East Timor, a half-island nation of 1.5 million people who are among the poorest in the world, the treaty is crucial to economic development and employment opportunities. Pereira said 65 percent, mostly young people, are looking for jobs.

Bishop told reporters that under the treaty East Timor will get the biggest share of revenue from exploiting the oil and gas. It will be split either 80-20 if gas is piped to Australia for processing or 70-30 if it is piped to East Timor, she said.

"We are talking billions of dollars over the life of such a resource project," Bishop said.

Pereira said companies have told East Timor that it is feasible to build a pipeline to the country.

"We believe seriously that a successful pipeline to the south coast of Timor would be a game changer and have a transformational impact on the socio-economic status of the country," he said.

The dispute has dominated and soured relations since 2002, when East Timor emerged as a fledgling nation independent of Indonesia.

The terms of the deal negotiated under the Conciliation Commission in The Hague, Netherlands, through the Permanent Court of Arbitration are expected to be made public shortly, Australian diplomats said.

East Timor achieving its ambition of a border midway between the two countries could encourage Indonesia to renegotiate its own much longer maritime boundary with Australia, agreed in 1971 under outdated international law. The Indonesian border with Australia extends east and west of the new East Timor-Australia boundary and the vast expanse Indonesia allowed Australia is a source of increasing irritation for the Indonesian government.

Bishop told reporters that she had kept Indonesian officials informed of the negotiations with East Timor on the maritime boundary.

East Timor's oil revenues, which finance more than 90 percent of government spending, are rapidly dwindling due to the exhaustion of existing fields in its territory. The country's $16 billion sovereign wealth fund could be empty within 10 years because the government's annual withdrawals are exceeding its investment returns, according to La'o Hamutuk, an East Timorese research institute.

Carlos Filipe Ximense Belo, the influential East Timorese Catholic bishop and Nobel Peace Prize laureate, welcomed the border resolution as an economic boon for his deeply Catholic country.

"We thank God because our sea becomes more widespread ... our economic zone becomes bigger," Belo said. "In the sea and on the sea bed, there is much wealth. Timorese will diligently explore and make this wealth contribute to us."

Portugal, East Timor's former colonial master, never had a border with Australia.

Australia began negotiating a border with Indonesia after the Indonesian military's brutal 24-year occupation of East Timor began in 1975. But by 1989, after a decade of talks, Australia and Indonesia agreed to disagree on where the line should be drawn for the sake of allowing oil and gas drilling in the resource-rich Timor Sea to proceed.

The rival border options became the north and south edges of a box called the Joint Petroleum Development Area. Australia and Indonesia shared the royalties piped from that disputed seabed.

Australia pressured East Timor into accepting the same border compromise in a 2002 treaty to provide legal certainty for developers of the massive Greater Sunrise oil and gas field, an untapped resource in the Timor Sea worth tens of billions of dollars.

Australia was widely criticized in 2016 over its unsuccessful rejection of the Permanent Court of Arbitration's jurisdiction to hear East Timor's border complaint. Many saw Australia as undermining its lecturing of China to abide by international law on Chinese territorial claims in the South China Sea.

Australia and East Timor signed a 2006 treaty on sharing future Greater Sunrise revenue. But the relationship plunged when East Timor accused Australian spies of bugging its Cabinet discussions to achieve an unfair negotiation advantage. Australia denied the allegation.

"Australia has an enduring interest in a stable and prosperous East Timor" and wants the country to achieve its economic potential, Bishop said.

East Timor's negotiating team was led by independence hero Xanana Gusmao, the nation's first president. Pereira said he could attend the treaty signing but was "here in spirit."

___

Associated Press writer Edith M. Lederer reported this story at the United Nations and AP writer McGuirk reported from Canberra, Australia. AP writer Oki Raimundos in Dili, East Timor, contributed to this report.