Zakka's release comes amid heightened tensions between Iran and the US after America's withdrawal from Tehran's nuclear deal with world powers. There was no immediate comment from US authorities on his release.
Zakka told reporters at the presidential palace Tuesday that the initiative to release him is a local one, made in Lebanon. In November 2015, Iranian state television announced Zakka was in Iranian custody, and accused of espionage. Relations have deteriorated sharply since US President Donald Trump took office in January 2017.
The White House says it is "thankful" for his release.
Nizar Zakka, an information technology specialist who holds USA residency, was sentenced to 10 years in jail and fined $4.2 million in 2016.
Iran on Tuesday freed Nizar Zakka, a US permanent resident and Lebanese national, from prison after almost four years behind bars, his lawyer said.
It broadcast photographs of a man in military uniform it said was of Zakka at a U.S. base.
A Lebanese official says a US permanent resident imprisoned for years in Iran is free and on his way to Lebanon.
Meanwhile, head of the Lebanese General Security, General Abbas Ibrahim left Beirut on Sunday heading for Tehran to complete efforts to release Zakka.
The official spoke to The Associated Press on condition of anonymity in line with regulations.
Shahindokht Molaverdi, an adviser to President Hassan Rouhani who as a vice president invited Zakka to Iran, told the AP in September that Iran's government had "failed" to help Zakka.
The potential release of Zakka, an internet freedom advocate, comes as tensions between Iran and the U.S. remain high.
Tehran has agreed to hand over a permanent United States resident imprisoned for years in Tehran to Lebanese officials, AP reported. The 52-year-old was being handed over to Lebanese officials.
This March 2013 handout image provided by the Friends of Nizar Zakka, shows Nizar Zakka, a Lebanese technology expert and advocate for Internet freedom, delivering a speech during the MENA ICT Forum conference in Jordan.
A top Lebanese security official is in Tehran to secure Zakka's release, which has been anticipated.
Lebanon's president and foreign minister had urged Tehran to grant an amnesty to Zakka, and Iranian officials said his release was partly due to the country's close ties with Lebanon's Hezbollah group.
He was arrested on the way to the airport and later sentenced to 10 years behind bars on espionage charges in a closed-door trial.