Iran said it will release US permanent resident Nizar Zakka, the Lebanese foreign ministry said on Monday.
President Hassan Rouhani is ready to receive a Lebanese delegation for Mr Zakka’s extradition, the foreign ministry statement said.
Mr Zakka’s brother confirmed his release, thanking all of those who helped to secure it.
The support of his friends and citizens of Lebanon "helped [keep] Nizar alive and helped him overcome the dark days he endured in Evin prison, especially during his numerous hunger strikes," his brother Ziad said.
He also thanked the country's President Michel Aoun and Gen Abbas Ibrahim, the head of Lebanon's most powerful internal security branch, for helping to secure Nizar's freedom.
Mr Zakka, 52, is a Lebanese citizen who was invited to Tehran in 2015 to attend a conference hosted by the Iranian government and was arrested shortly before departing for Beirut. Soon after his arrest, Iran State TV said Mr Zakka was a spy.
His release comes after mediation efforts by top Lebanese officials, including President Aoun and Prime Minister Saad Hariri.
In September 2016, Mr Zakka was sentenced to 10 years in prison and, handed a $4.2 million fine on espionage charges. His family deny the allegations.
Mr Zakka was held in Evin prison, a notorious jail, where a number of political prisoners and dual nationals are being held, including British-Iranian mother Nazanin Zaghari-Ratcliffe.
The Lebanese IT expert was reportedly interrogated about his work, forced to give his email address and password, and denied access to his family.
Lebanese officials have intermittently pushed for his release but his family have criticised the foreign ministry for not doing more.
To protest against his detention, he has on several occasions undertaken hunger strikes, which have impacted affected his health, his US-based lawyer Jason Poblete has said.
In February this year, Mr Zakka announced an indefinite hunger strike, demanding Lebanon’s newly formed cabinet include a commitment to hostages in its policy statement.
As a permanent US citizen, Mr Zakka’s imprisonment became a political issue in the United States too, although it is not clear what role, if any, America played in his release.
According to a website dedicated to the cause of Zakka's freedom, he is a prominent IT expert who specialises in Arab information and communications. He has worked for Cisco, Microsoft and contractually for the USAID, according to the Free Nizar Zakka website.
Mr Ibrahim is garnering a reputation as an effective force in Lebanese politics, and has been tasked with undertaking a string of difficult negotiations, including with militant groups and Al Qaeda affiliates. He built contacts and praise as a savvy negotiator during his time as head of security for south Lebanon that involved building the trust of numerous armed groups that operate in the Palestinian refugee camps, and he brokered several ceasefires after rounds of fighting.
Perhaps his most high-profile deal came in 2017 when he managed to get ISIS militants on the Lebanese border to give up the locations of bodies of Lebanese soldiers kidnapped when they overran the north-eastern town of Arsal three years previously.
The remains of eight soldiers were recovered from the mountainous border area between Syria and Lebanon, bringing closure to the families who had been holding a years-long sit-in outside the prime minister’s office demanding the government locate find the remains of their sons.
While it remains unclear if Gen Ibrahim’s discovery of the bodies was tied to the larger deal to end a Hezbollah offensive against the ISIS militants who had held the soldiers, shortly after they were returned to Beirut the fighters were allowed to leave by bus for Syria’s Deir Ezzor.