Updated

A federal judge has ordered the release of Lynne Stewart, a terminally ill former defense lawyer convicted of assisting terrorism.

U.S. District Court Judge John G. Koeltl ordered Stewart's release Tuesday on grounds of compassion after a request from the director of the Bureau of Prisons through the office of U.S. Attorney Preet Bharara. The request said that Stewart was entitled to a compassionate release because she had been diagnosed with a terminal, incurable illness, and given less than 18 months to live.

"The defendant’s terminal medical condition and very limited life expectancy constitute extraordinary and compelling reasons that warrant the requested reduction," Judge Koeltl said in his order reducing Stewart's sentence to time served.

Stewart was convicted in 2005 on charges that she smuggled messages from Sheikh Omar Abdel Rahman to his followers in Egypt. Stewart had defended Rahman from charges that he conspired to blow up New York City landmarks. Rahman was convicted in 1995. Stewart was sentenced to 10 years in prison, which she had been serving at the Federal Medical Center Carswell, in Fort Worth, Texas.

"It's just really wonderful," Stewart said in a telephone interview with the Associated Press. "I'm very grateful to be free. We've been waiting months and months and months."

Stewart left the prison late Tuesday with her husband, Ralph Poynter, en route to New York.

"It's a great way to start the new year," Poynter said.

Stewart was diagnosed with breast cancer in 2005 and a court filing said that the cancer had spread to her lungs and bones.  A previous compassionate-release request was denied in part on the grounds that Stewart had more than 18 months to live, though the judge said he would act promptly if the Federal Bureau of Prisons agreed she had less than 18 months to live and granted a compassionate-release application.

A federal appeals court in 2012 upheld Stewart's 10-year sentence, saying she earned it through serious crimes that she refused to acknowledge. The 2nd U.S. Circuit Court of Appeals said it was fair to boost Stewart's sentence from the two years and four months she was given in 2006.

The three-judge panel that had ordered Stewart to be resentenced said it disagreed with her claim that her sentence was "shockingly high." It accused her of exhibiting a "stark inability to understand the seriousness of her crimes."

The Associated Press contributed to this report.