In a dramatic prisoner exchange at the border between Lebanon and Syria, al Qaeda's Syrian wing swapped 16 Lebanese soldiers and policemen for the release of 13 jailed Islamists — including the ex-wife of Islamic State (IS) leader Abu Bakr al-Baghdadi.

Live TV footage of the swap showed the Lebanese captives in vehicles accompanied by masked men armed with assault rifles and waving the Nusra Front flag. The Nusra fighters chanted "God is great," before they released their captives to the Red Cross.

The most prominent prisoner released from Lebanon was Saja al-Dulaimi, the ex-wife of IS head al-Baghdadi. Dulaimi, fully veiled, was shown in live TV footage with her three children, who were with her in prison. Nusra Front fighters were shown kissing and hugging her sons, who were also arrested by the Lebanese authorities a year ago. Speaking to al-Jazeera, she said her wish was to return to Beirut and then to leave to Turkey "I am Abu Bakr al-Baghdadi's ex-wife." she said. "We have been divorced for over six years now. I will head to Beirut and plan on leaving to Turkey."

Nusra Front militants seized the Lebanese soldiers during an attack it conducted at the same time as its enemy the Islamic State (IS) on the Lebanese border town of Arsal in August, 2014. For over a year, Nusra had demanded that the Lebanese government free Islamist prisoners in exchange for the captives. The Lebanese had been hesitant, and Nusra has since killed four prisoners to force Beirut's hand. For months, the relatives of the captives had camped outside government headquarters in Beirut to advocate for a prisoner exchange.

"We accomplished the entire agreement with Nusra. We received our heroic soldiers and we are on our way back to Beirut," Lebanon's domestic intelligence chief, Abbas Ibrahim, who oversaw the swap, told Reuters.

After the swap, one of the captives, interviewed by al-Jazeera, said the group had treated them well.

"Praise be to God. The joy cannot be described," another captive told al-Jazeera.

The freed soldiers and policemen were carried aloft during celebrations in the town of Labweh near the Lebanese border where they briefly stopped on their way to Beirut. Politicians from across the political spectrum congratulated the men on their release.

Relatives of the captives celebrated at a tented sit-in they have held near the government's headquarters in Beirut since last year to press for negotiations. There was dancing and sweets were offered to visitors who went to congratulate them.

"I was born again today, this is a rebirth for me and my brother. It has been a year and five months of agony for the soldier's' parents, my parents and me," Marie Khoury, the sister of freed soldier George Khoury told Reuters at the sit-in.

The deal was brokered by Qatar and suggests that the wealthy Gulf monarchy wields some influence on the Nusra Front, a powerful player in the Syrian civil war that has been designated a terrorist group by the United Nations and United States. Qatar has been involved in efforts to mediate the release of the captives for a year or more. A previous effort to secure their release broke down a year ago after one of the captives was killed. The Qatar National News Agency said the successful mediation followed a request from the Lebanese government.

Qatar has been a major sponsor of the insurgency against President Bashar al-Assad, supporting rebels including groups deemed moderate by the United States. It has denied backing the Nusra Front or Islamic State.

In the same August, 2014 raid, IS also took Lebanese prisoners who are still being held. On Tuesday, Wael Abu Faour, Lebanon's health minister, told al-Jazeera that efforts had been under way to negotiate a similar deal with IS.

"We will do our best to secure the release of the remaining hostages," he said. "There had been some channels, through mediators."

But since IS militants attacked Paris last month, French and coalition warplanes have been pounding the IS capital of Raqqa, and negotiations for a prisoner swap have been on hold, Abu Faour said. After today's successful exchange, Abu Faour said, there's new hope for talks with IS to release the remaining prisoners.