This month, without a shot being fired, Israel gave up land to an Arab neighbour.

The flag of Jordan was raised above Baqoura and al-Ghamr, two tracts along the kingdom’s border with Israel, recognised as Jordanian land but leased to the Jewish state as part of a landmark 1994 peace deal between the two countries.

The bloodless handover of the territories, as well as Jordan’s staunch refusal to renew Israeli leases on them, was a fitting 25th anniversary for a peace treaty that has proved extraordinarily unpopular yet stubbornly durable. The Israel-Jordan peace agreement has survived massacres, poisoning attempts and the rightward drift of Israeli politics, and now may face its greatest test in Donald Trump’s efforts to reshape the Middle East.

“Are we better off now, 25 years since the deal was signed? I don’t think we are, not economically nor politically,” says Dureid Mahasneh, a former Jordanian official who helped to negotiate key water and transport agreements with the Israeli side. “We ended hostilities, and that’s progress, but nothing beyond that.”

“I would say it is still working,” says Jawad Anani, a former Jordanian deputy prime minister who was part of the negotiating team for the deal. “Neither side has shown any inclination or desire to give it up, despite all the acid tests it has gone through.”

The treaty, only the second Arab-Israeli peace deal after the 1979 agreement with Egypt, is the product of a lost era. “It was a rare alignment of people willing, genuinely, to strike peace,” says Osama al-Sharif, an Amman-based political analyst.

In the early 1990s, Jordan was under economic pressure, ostracised by its traditional patrons in the Gulf for being seen to go soft on Saddam Hussein’s invasion of Kuwait. The Oslo accords between Israel and the Palestinian Authority had been signed a few months before, raising hopes that a solution to the region’s most intractable conflict could be within reach.

And then there was the chemistry between King Hussein, Jordan’s ruler at the time, and the then Israeli prime minister Yitzhak Rabin. “It was this charm King Hussein felt for Rabin and vice versa,” says Sharif. “There was personal chemistry between these two men, and a vision for a new Middle East, a riviera along the Red Sea, extending from [Egypt’s] Sharm el-Sheikh to [Jordan’s] Aqaba through [Israel’s] Eilat.”

The high hopes when the deal was signed on 26 October 1994 were dashed in the crackle of gunfire. “Just as the deal was expanding we had the assassination of Rabin, which truncated the whole process,” says Sharif, echoing the popular Jordanian view. “And the rise of one man who undid everything, whose name is Benjamin Netanyahu.”

The treaty was tested from almost its inception. In 1997, a Jordanian soldier on duty in a part of Baqoura known as the “Island of Peace” opened fire on a group of Israeli schoolgirls on an excursion to the site, killing seven. It required a personal visit to the victims’ families by Hussein, who kneeled before them in contrition, to keep relations on track.

Facebook Twitter Pinterest Jordanian policewomen in Baquora, Jordan. Photograph: Xinhua/Barcroft Media

The same year, in a spectacularly bungled operation, a team of Mossad operatives entered Jordan on fake passports and attempted to poison a Hamas leader, Khaled Mashaal. The agents managed to spray Mashaal with a deadly chemical, but were caught trying to flee the scene. The Hamas leader collapsed into a coma within hours.

Informed of the attempted assassination, Hussein warned that if Mashaal died, the deal would expire too. Reluctantly, and under US pressure, the Israeli government dispatched its spy chief to Amman with an antidote to the substance its agents had administered to one of its key nemeses, bringing him back to life.

More recently, observers on both sides argue the treaty has been severely strained by the rightwing turn of Israeli politics led by Netanyahu, the country’s longest-serving prime minister. His government has used a mutual fear of Iran to quietly soften relations with Saudi Arabia and the Gulf states, who in turn are perceived to have disengaged from the Palestinian issue.

But around 70% of Jordan’s population are Palestinian refugees or their descendants. The kingdom’s official position is that they will one day return to a state of their own. The growing occupation of the West Bank, as well as announcements such as Netanyahu’s election-eve pledge to annex swathes of the occupied Jordan valley are treated in Amman as an existential threat.

“I see great danger to the peace treaty,” the former Mossad chief Efraim Halevy said at an Israeli research institute in September. “The Israeli lack of attention and real analysis of this issue, taking Jordan for granted, as a state having no choice but relying on Israel, are the factors severely endangering the treaty’s existence.”

Nimrod Goren, the founder and head of Mitvim, an Israeli thinktank that works to promote Arab-Israeli relations, said every time there was tension with the Palestinians, it played out in Jordan-Israel ties. “That is something the [Israeli] government tries not to acknowledge. They try to say that Arab relations are now unrelated to the Israeli-Palestinian track. It’s the Netanyahu narrative.”

Nearly 70% of Jordanians are now in favour of limiting ties with Israel, according to a recent survey, the inverse of an Israeli poll that found 71% of people there back the treaty. One of the few commercial ventures to get off the ground under the deal, an agreement for Jordan to buy Israeli natural gas, continues to spark protests in Amman. The Centre for Israel Studies, the only Jordanian NGO that seeks to grow relations between the two countries, operates virtually in secret, declining to promote its events or invite media.

“It’s a hostile environment,” says the centre’s founder, Abdullah Sawalha. “We try to keep a low profile because most people don’t understand the mission.”

Yet the treaty survives, sustained in large part by the open secret that Jordanian and Israeli security services cooperate closely to secure their shared border from militants and smugglers. “Both parties, Israelis in terms of their own security, and Jordanians in terms of their security and ability to negotiate and continue engaging the Israelis, want to keep it,” says Anani, who also served as Jordan’s foreign minister.

The deal also helps to smooth the way for annual US aid payments worth more than $1.5bn each year that keep Jordan’s donor-dependent economy afloat.

To reach its 30th anniversary, the treaty will first need to survive the machinations around the so-called “ultimate deal”, the Trump administration’s anticipated plan to build peace with Israelis and Palestinians. Jordanians fear a barnstorming Trump peace drive could rob the country of its special role in maintaining Jerusalem’s important Muslim sites, cement the occupation of Palestinian territories or further sideline Jordan as the Arab world’s chief interlocutor with Israel.

The overwhelming preference of Jordan’s government will be to remain in the treaty, says Anani. “Jordan’s position is that, OK, if there is [Trump’s] ‘deal of the century’, let’s negotiate our way out of it,” he says. “And can we do that better with a peace treaty with Israel than without it.”

But even in a country with limited democracy, popular opinion can only be managed for so long, others warn. “The treaty is a double-edged sword,” says Sharif. “It helps Jordan achieve certain goals, but it can also hurt Jordan, because once we exhaust all diplomatic channels to exert pressure on Israel … What do we do then?”