When the leaders of Ethiopia and Eritrea embraced in Asmara last month, promising to end the two-decade-old state of war between their two countries, it looked like a sudden breakthrough.
But the rapprochement was, in fact, the culmination of a year of back-channel talks, sources with knowledge of the matter told Reuters.
One of the drivers behind that process was the United States, which has been a major player in the Horn of Africa for decades.
More surprising was the role played by a much smaller nation: the United Arab Emirates.
The oil-rich Gulf state has gained increasing influence in the region in recent years, according to UAE and Ethiopian officials and diplomats.
Driven in part by a desire to tap Ethiopia's growing economy and in part by a fear that rivals such as Iran and Qatar could gain a foothold in the Horn of Africa, the UAE has pushed into the region for more than a decade.
Its newfound assertiveness underscores the shifts underway in the continent, where China now challenges the historic power of Western nations and where Russia, Brazil and the UAE and its Gulf States are growing in prominence.
Publicly, the UAE downplays its influence. Minister of State for International Cooperation, Reem al-Hashimy, told an event in Washington last month that her country had "played a humble role in trying to bring these two countries together".
But two diplomats in the Gulf told Reuters that the UAE has privately taken credit for the peace agreement.
The Ethiopian prime minister's chief of staff, Fitsum Arega, acknowledged meetings with UAE officials but said the leaders of Ethiopia and Eritrea were responsible for ending the war.
Eritrea's information minister, Yemane Ghebremeskel, was not available for interview when Reuters visited the country's capital, Asmara, last month.
The UAE has enjoyed virtually unchallenged influence in Eritrea for at least a decade.
Eritrea is the most diplomatically isolated state in Africa. The United Nations imposed sanctions including an arms embargo in 2009, accusing the government of supporting Islamist militants in neighboring Somalia — a charge it denies.
But Abu Dhabi has a military base there which it uses to help prosecute the war in Yemen, located just across the Red Sea.
Earlier this year, Hashimy, the UAE minister, met with Ethiopian Prime Minister Abiy Ahmed's predecessor, Hailemariam Desalegn, in Ethiopia.
When Abiy took office in April, Abu Dhabi ramped up that effort. The timing was fortuitous: the UAE's relationship with Somalia, another nation in the Horn of Africa, was falling apart and Abu Dhabi was looking for a new partner.
"After years of investing in Somali security forces, the UAE saw its gains swept away by what it perceived to be an axis of Qatari and Turkish influence," said Elizabeth Dickinson of the International Crisis Group.
A month after taking office, Abiy visited the UAE capital Abu Dhabi to meet Crown Prince Sheikh Mohammed bin Zayed al-Nahyan. The new Ethiopian leader offered to mediate between Abu Dhabi and Somalia, two diplomats in the Gulf said.
Officials from the UAE affiliate of the Red Crescent society, Emirates Red Crescent, later visited Ethiopia to discuss aid projects with Abiy.
Those visits complemented efforts by Washington to move toward a restoration of relations between Ethiopia and Eritrea.
The United States has been conducting shuttle diplomacy for more than a year, according to regional diplomats. In 2017, Eritrean officials visited Washington twice and again once this year, leaving messages that the Americans passed to Ethiopian officials.
In late April this year, Donald Yamamoto, then the top US official on Africa, met Eritrean President Isaias Afwerki in Asmara — the first visit by a US official of that rank in more than a decade — before meeting Abiy in the Ethiopian capital.
With the promise of financial support from the Gulf and with Washington's backing, Abiy made his move.
"Neither Ethiopia nor Eritrea benefit from a stalemate," he said on June 6, a day after his ruling coalition, the Ethiopian People's Revolutionary Democratic Front (EPRDF), announced it would implement a peace deal with Eritrea dating back to 2000.
"We need to expend all our efforts towards peace and reconciliation and extricate ourselves from petty conflicts and divisions and focus on eliminating poverty."
Nine days later, Sheikh Mohammed visited Addis Ababa with officials including Sultan Ahmed al-Jaber, the head of the state-owned oil company.
The prince announced a $3 billion support package, made up of a $1 billion deposit in Ethiopia's central bank and a pledge of $2 billion in investments.
Ethiopian officials said the deposit, plus an offer from Saudi Arabia of a year's supply of fuel with payment delayed for 12 months, helped ease a foreign exchange crisis that had caused shortages of medicine and a slowdown in manufacturing.
"[The UAE's] good relationship with both parties helped with re-establishing the relationship between Ethiopia and Eritrea and we see that as a positive thing," Saad Ali Shire, Foreign Minister in the semi-autonomous state of Somaliland told Reuters.
It's been a long time coming.
Ethiopia and Eritrea are linked by blood and history. An Eritrean secessionist movement helped overthrow a military regime in Addis Ababa in 1991 and the new Ethiopian government then gave Eritrea its independence.
For a few years, the two countries co-existed peacefully. Landlocked Ethiopia depended on Eritrea's main port, which sits on one of the world's busiest shipping lanes.
But in 1998, the two went to war after a border dispute. Two years of brutal fighting left at least 80,000 dead. A shaky ceasefire followed.
Things finally began to change after the death of Ethiopian Prime Minister Meles Zenawi in 2012. Members of his ruling coalition began quietly discussing how to approach Isaias Afwerki in Eritrea.
"It became clear to us that normalization was not only beneficial to Ethiopia but for the entire region," said Hailemariam, who succeeded Meles before resigning in February.
Ethiopia's ruling coalition agreed in principle during Hailemariam's tenure to accept the peace deal and withdraw Ethiopian troops from a border town awarded to Eritrea in 2002, he said. His story was confirmed by other senior politicians and diplomats in Ethiopia.
But it was the appointment of Abiy that really encouraged Eritrea, Ethiopian officials, politicians and diplomats in the region say.
Preaching forgiveness and an end to the Ethiopian state's preoccupation with security, Abiy cuts a very different figure from his two predecessors.
"The PM made it clear he will work to ensure lasting peace and ... he proved himself through real gestures like releasing political prisoners," said his chief of staff Arega.
Abiy was able to act because his party had seen off the Tigrayan People's Liberation Front, long the dominant force within the ruling coalition and traditionally opposed to Eritrea.
When Isaias, the Eritrean leader, accepted the olive branch, he praised Abiy and welcomed the TPLF's weakening grip on power.
When Abiy and Isaias embraced last month, some in Africa likened the moment to the fall of the Berlin Wall.
A few weeks later the two leaders traveled to Abu Dhabi. A photo from that meeting shows the two men holding hands with the crown prince as he led them up a palace staircase.
Maggie Fick and Alexander Cornwell of Reuters reported from Addis Ababa, Ethiopia, and Dubai, UAE.