Nine Lebanese Shia pilgrims who were kidnapped by rebels in Syria in May 2012 have arrived back in Beirut a day after being released.
There were jubilant scenes as they were greeted on the tarmac by family members and Lebanese politicians.
Two Turkish pilots who were being held hostage in Lebanon were also freed as part of a complex swap.
Murat Akpinar and Murat Agca were seized in Beirut in August in a retaliatory abduction.
They were met by their relatives and Turkish Prime Minister Recep Tayyip Erdogan after flying to Istanbul on a Qatari jet late on Saturday.
A third part of the hostage negotiations – reportedly mediated by Qatar, Turkey and the Palestinian Authority – involved the release of a number of female prisoners being held by the Syrian government.
It is not yet clear whether that has taken place.
The 17-month ordeal for the nine Lebanese pilgrims is finally over. The scenes when they arrived at the VIP lounge at Rafik Hariri Airport were incredibly emotional. There were hugs and there were cries. Some people were so emotional they fell to the ground.
The group looked exhausted. They all insisted they had been treated very well by the Syrian opposition but they did say the conditions in which they had been kept were very, very difficult, especially the last four days.
Two things needed to happen for them to be released. Two Turkish pilots who were kidnapped two months ago are back home in Turkey. We also believe about 130 female Syrian prisoners were being released by the Syrian government from its detention centres.
The Lebanese group, all men, were released by their captors on Friday evening and driven to Istanbul, from where they flew to Beirut.
At the airport they were greeted by friends and family, as well as politicians and religious leaders.
The men appeared tired but in good health.
“A whole year passed and each of us never slept more than two hours a night due to exhaustion and too much thinking about what would or could happen to us,” one told the BBC.
Others described being kept in dark and windowless rooms and hearing heavy fighting.
“Our abductors didn’t respect us, they treated us badly,” Ali Zogheib was quoted as saying by Lebanese media.
“We wished that any of them had any kind of values”, another said of his captors. One of the pilgrims thought they had been held close to the Syrian border with Turkey.
The BBC’s Jim Muir in Beirut says it is clear that huge effort has gone into producing the complicated deal.
Lebanon’s security chief Maj Gen Abbas Ibrahim, who co-ordinated the hostage release, said it had been “difficult, without a doubt”.
“I didn’t want anything from this deal, except to see this sight,” he said, gesturing at the cheering crowds.
The nine Lebanese were among 11 people seized while making their way back to Lebanon after a tour of holy sites in Iran. Two of them escaped.
They were reportedly being held in northern Syria by fighters from a Sunni-based rebel group opposed to Syrian President Bashar al-Assad.
The rebels insisted their hostages were fighters with the Lebanese Shia militant group Hezbollah, and were demanding the release of women detainees held by the Syrian regime in exchange.
Then in August, Murat Akpinar and Murat Agca were seized from a bus close to Beirut’s international airport. A previously unknown group called Zuwwar al-Imam Rida said it had kidnapped them, and that they would be freed if the Lebanese group were set free.
It demanded that Turkey used its influence with Syrian rebels to make the swap possible.
In response, Turkey advised its citizens in Lebanon to leave if possible.
Turkey has consistently backed Syria’s Sunni rebels, while much of Lebanon’s Shia community supports President Bashar al-Assad.
The pilots’ abduction sparked protests in Lebanon, and growing concerns that the Syrian civil war was spilling over the border.
Earlier this week they appeared in a video broadcast on Lebanese television saying they were both well and wanted to go home.
Then, as word came late on Saturday that the Lebanese pilgrims were back in Beirut, the pilots arrived in Istanbul.
They told Turkish media that they had been treated well in captivity.
But Mr Akpinar told the Hurriyet newspaper that “first month has been very difficult”.
“We have been transferred eight times, each time as if it was a new kidnapping.”
“We chose to have a good understanding with them. And we did, so much that one of our (kidnappers) has even decided to call his new son Murat,” Mr Akpinar added.
Syrian and Lebanese politics have been deeply intertwined throughout the history of the two states.
Syria had a large military presence in Lebanon for 29 years. It finally withdrew its soldiers in 2005, but has maintained a strong influence.
The conflict in Syria, now in its third year, has claimed more than 100,000 lives and created more than two million refugees.
Our correspondent says that while the war rages on, the hostage exchange creates a small glimmer of hope as efforts intensify to arrange a peace conference in Geneva next month.
Top photo: Relatives of some of the nine Lebanese Shiite pilgrims, who were kidnapped by a rebel faction in northern Syria in May 2012, hug each other as they celebrate news of their relatives release, in the southern suburb of Beirut, Lebanon, Saturday, Oct. 19, 2013. (AP Photo/Hussein Malla)