Fars, the Iranian news agency, said Mr. Zakka was released out of respect for Hassan Nasrallah, the leader of Hezbollah, the Lebanese military and political group that the United States considers a terrorist organization. Hezbollah is deeply intertwined with Iran, and is part of Lebanon’s coalition government.

Mr. Zakka was “freed and extradited, thanks to Nasrallah’s mediation and the respect Tehran pays to him,” the news agency said.

Abbas Ibrahim, the head of Lebanon’s internal security agency, went to Tehran to meet with Mr. Zakka on Monday, his office said in a statement.

Though Mr. Zakka’s son met with Secretary of State Mike Pompeo this year to urge him to help secure his father’s release, American officials have not acknowledged any efforts on Mr. Zakka’s behalf by the United States. Iran’s foreign minister, Mohammad Javad Zarif, offered this year to discuss prisoner releases with the United States — a move interpreted as a signal that the Iranians wanted to pursue diplomacy — but American officials did not take him up on the offer.

Mr. Zakka was arrested in September 2015 on his way to the airport in Tehran, where he had attended a conference, according to advocates for Mr. Zakka, even though he had received an official invitation from Iran’s vice president for women and family affairs to speak at the event.

Iranian state television reported that he was suspected of having “deep links” to American intelligence, and he was convicted of spying, sentenced to 10 years in prison in September 2016 and ordered to pay a $4.2 million fine.

At the time of his arrest, he was the secretary-general of IJMA3, an association for information technology organizations across the Middle East and North Africa. The association had received funding from the State Department, the United States Agency for International Development and international aid groups, Mr. Zakka’s advocates said.