He was a Lebanese immigrant named Ali Kourani, and he told the F.B.I. that he was a sleeper agent for a terrorist organization. He said he was scouting targets in New York City for possible attacks, including airports and government offices, while leading a second life as a telephone salesman and family man.

The plan, he told agents, was for him to become a suicide bomber.

Over a series of five meetings, Mr. Kourani believed he was offering this and other information to the F.B.I. in exchange for leniency from the United States government and protection for his family.

But instead, the F.B.I. arrested him in June 2017 and charged him with eight counts related to terrorism. In May, a Manhattan jury convicted Mr. Kourani on all charges — largely as a result of what he had told the agents.

On Tuesday, in federal court in Manhattan, Mr. Kourani was sentenced to 40 years in prison, less than the life sentence prosecutors had sought but more than his lawyer said he deserved. In the end, he told the court that the government was “overreaching” and that his ties to the terrorist organization Hezbollah were strictly political.