NEW YORK, Oct 27 (Reuters) - A Manhattan federal judge on Tuesday ordered that a former New York City accountant who admitted to scoping out the New York Stock Exchange for al Qaeda be released early from his 18-year prison sentence.

U.S. District Judge Kimba Wood said Sabirhan Hasanoff, 44, of Brooklyn, had shown "extraordinary and compelling" reasons for being resentenced to time served under a law allowing the early "compassionate release" of some prison inmates.

Wood, who sentenced Hasanoff in 2013, cited evidence he was the only available caregiver for his mother, who is in poor health, and his "striking and unique efforts" to rehabilitate himself since his April 2010 arrest.

She said these included working in a chapel at the Otisville, New York, federal prison, teaching classes focused on tolerance and moderation in Islam, and teaching accounting and finance classes.

While Hasanoff's crimes were "extremely serious," Wood wrote that "this is a rare case in which a defendant exceeds the bounds of what we consider rehabilitation."

The office of Acting U.S. Attorney Audrey Strauss in Manhattan, which opposed Hasanoff's release, did not immediately respond to requests for comment.

"This is a just and compassionate result," Hasanoff's lawyer, Joshua Dratel, said in an email.

Prosecutors said Hasanoff supported al Qaeda from 2007 to 2009, including by performing surveillance on the NYSE, and sending remote-control devices that could be used in explosives attacks to operatives abroad.

Hasanoff, a dual U.S. and Australian citizen, had worked at the accounting firms KPMG and PricewaterhouseCoopers.

He pleaded guilty in June 2012 to supporting al Qaeda and conspiring with other people.

A co-defendant, Wesam el-Hanafi, who has serious health problems, recently had his own sentence shortened to time served, Wood said.

The case is USA v. el-Hanafi et al, U.S. District Court, Southern District of New York, 10-cr-00162. (Reporting by Jonathan Stempel in New York; Additional reporting by Mark Hosenball in Washington, D.C. Editing by Matthew Lewis)