JERUSALEM (AP) — Israel’s prime minister said Tuesday that the country has reached a “historic agreement” with neighboring Lebanon over their shared maritime border after months of U.S.-brokered negotiations.

The agreement would mark a major breakthrough in relations between the two countries, which formally have been at war since Israel’s establishment in 1948. But the deal still faces some obstacles, including legal and political challenges in Israel. Lebanese officials indicated they would approve the agreement.

At stake are rights over exploiting undersea natural gas reserves in areas of the eastern Mediterranean that the two countries — which do not have diplomatic relations — claim. The agreement is expected to enable additional natural gas production in the Mediterranean. Lebanon hopes gas exploration will help lift its country out of its spiraling economic crisis, while Israel also hopes to exploit gas reserves while also reducing tensions with its northern neighbor.

Israeli Prime Minister Yair Lapid called the deal a “historic achievement that will strengthen Israel’s security, inject billions into Israel’s economy, and ensure the stability of our northern border.”

Lebanon and Israel both claim some 860 square kilometers (330 square miles) of the Mediterranean Sea. Under the agreement, those waters would be divided along a line straddling the strategic “Qana” natural gas field.

According to a senior Israeli official, Lebanon would be allowed to produce gas from that field, but pay royalties to Israel for any gas produced from the Israeli side. Lebanon has been working with the French energy giant Total on preparations for exploring the field.

The agreement would also leave in place an existing “buoy line” that serves as a de facto border between the two countries, the official said. He spoke on condition of anonymity because he was discussing behind-the-scenes negotiations.

Many leading security figures, both active and retired, have hailed the deal because it could lower tensions with Lebanon’s Hezbollah militant group, which has repeatedly threatened to strike Israeli natural gas assets in the Mediterranean. With Lebanon now having a stake in the region’s natural gas industry, experts believe the sides will think twice before opening up another war.

The two sides fought a monthlong war in 2006, and Israel considers the heavily armed Hezbollah to be its most immediate military threat.

“It might help create and strengthen the mutual deterrence between Israel and Hezbollah,” said Yoel Guzansky, a senior fellow at Israel’s Institute for National Security Studies. “This is a very positive thing for Israel.”

The final draft of the agreement will be brought before Israel’s caretaker government for approval this week ahead of the Nov. 1 election, when the country goes to the polls for the fifth time in under four years.

An Israeli official said the Cabinet is expected to approve the agreement in principle on Wednesday, while sending it to parliament for a required two-week review. After the review, the government would give final, official approval, the official said, speaking on condition of anonymity to discuss government strategy. It remains unclear, however, if parliament needs to approve the agreement, or merely review it.

Approval is not guaranteed. Former Prime Minister Benjamin Netanyahu has claimed Lapid does not have the authority to sign an agreement and vowed to cancel what he calls a “disgraceful deal” if re-elected.

The Kohelet Policy Forum, an influential conservative think tank, already has filed a challenge to the Supreme Court trying to block the deal.

Eugene Kontorovich, the forum’s director of international law, claimed the agreement requires parliamentary approval. He accused the government of trying to rush through an agreement under pressure from Hezbollah. “This means Hezbollah now overrides Israel’s democracy,” he said.

Senior U.S. energy envoy Amos Hochstein, whom Washington appointed a year ago to mediate talks, delivered a modified proposal of the maritime border deal to lead Lebanese negotiator, Deputy Speaker Elias Bou Saab late Monday night, according to local media and officials.

President Michel Aoun’s office said the latest version of the proposal “satisfies Lebanon, meets its demands, and preserves its rights to its natural resources,” and will hold consultations with officials before making an announcement.

A senior official involved in the talks told The Associated Press that Aoun, Prime Minister Najib Mikati, and Speaker Nabih Berri are all satisfied with Hochstein’s latest reiteration of the maritime border deal. The official spoke on condition of anonymity in line with regulations.

Hezbollah did not immediately comment, but its leader, Hassan Nasrallah, has said that the group would endorse the Lebanese government’s position. In the past, however, he has threatened to use its weapons to protect Lebanon’s economic rights.

Nasrallah was expected to make an official statement later Tuesday.