New York (CNN) -- A New York imam who pleaded guilty to lying to federal agents as they investigated an alleged terror plot was sentenced Thursday to time served and ordered to leave the United States within 90 days.

A plea agreement had recommended a sentence of up to six months in prison for Ahmad Wais Afzali.

"I take full responsibility for my actions," Afzali told a federal judge during the sentencing hearing. "Honest to God, it was never my intention to help those idiots for what they do in the name of Islam" he added, an apparent reference to a phone call to Najibullah Zazi that federal authorities said blew the cover on their investigation of the terror plot.

Afzali elaborated on that comment after his sentencing in front of gathered press. Afzali said of Zazi, "Not only does he give himself a hardship and his family; also in a certain degree he's making it hard for every other Muslim that lives in America."

This week, new details emerged indicating that Zazi and two suspects planned to attack trains at New York City's Times Square and Grand Central stations, according to a law enforcement source.

Afzali was originally charged in a four-count indictment but pleaded guilty to the one charge. He was accused of lying about whether he tipped off suspect Zazi that the FBI had been asking questions about his activities. Zazi subsequently pleaded guilty to conspiring to detonate explosives in the United States.

Afzali, a Muslim cleric and funeral director from the New York borough of Queens, was one of the first people charged in the investigation.

During a plea hearing in March, Afzali told the court that police had asked him to help provide information about Zazi and two other suspects, Adis Medujanian and Zarein Ahmedzay. He said he knew Zazi and Medujanian fairly well from when the men were teenagers and would attend his mosque for prayers and to play volleyball.

"The police interest in these men led me to believe that they were involved in some criminal activity, but I had no idea of its seriousness," Afzali said after his March plea hearing, at times choking up during his statement.

He said he called Zazi on September 11, 2009, a day after he was contacted by authorities. "I told him that our phone call was being monitored. I told Zazi, 'Don't get involved in Afghanistan garbage and Iraq garbage, that's my advice to you.' "

"On September 13 ... I was interrogated by FBI agents for the first time. I believed that the FBI was angry at me for calling Zazi," he added. "When I was asked whether I had told Zazi about law enforcement being interested in him, I lied and said I did not. My intention was not to protect Zazi, but to protect myself."

He admitted to repeating the lie during another interview with prosecutors a few days later, saying, "In doing so, I failed to live up to my obligation to this country, my community, my family and my religion. I am truly sorry."

The Afghanistan-born Afzali walked out of the courthouse Thursday wearing an electronic monitor, a stipulation of the plea deal.

"The sad part is that I have to say goodbye to the only country that I know. My kids are born here and my family lives here, it's going to be a tough transition," he said.

Asked where he was planning to go, Afzali said, "I would love to go to Canada, the closest country to America ... but it all depends on the country and its regulations."

Before entering his plea, the 38-year-old imam placed a scarf on the floor outside the courtroom and prayed. He later told reporters that he "just signed his death sentence" by accepting the plea deal, saying he didn't want to leave the United States.

The two other suspects in the case, Ahmedzay and Medunjanin, pleaded not guilty in February to new charges of conspiracy to use weapons of mass destruction against persons or property in the United States, as well as several other counts. The two had previously faced lesser charges.

Prosecutors say the men -- 25-year-old U.S. citizens and residents of Queens -- conspired with Zazi "to attack the New York subway system in mid-September 2009."

A fourth suspect in the case is in custody in Pakistan, according to a law enforcement source.

CNN's Susan Candiotti and Miguel Susana contributed to this report.