The District’s chief financial official said Friday that he will leave his post in June, less than a year after he accepted a new five-year term as the city’s fiscal cop.

“This was not an easy decision,” Natwar Gandhi said in a letter to Mayor Vincent Gray. “I feel comfortable retiring at this time because the city is in excellent financial condition, perhaps the best in its history.”

Gandhi’s decision to leave the corridors of power came after weeks of speculation about his future in city government and days after he announced that the District had recorded a $417 million budget surplus in the 2012 fiscal year.

Gandhi’s spokesman, David Umansky, characterized the CFO’s decision as a “retirement” that was for “purely personal reasons.”

Gandhi became the city’s independent CFO in 2000 and won widespread respect on Wall Street for his management of the District’s finances, which were so suspect in the 1990s that the federal government seized control of D.C.’s coffers and ratings agencies gave its bonds “junk” status.

But under Gandhi, the District rebounded and its savings account, which once had a deficit of more than $500 million, climbed to $1.5 billion.

For all of the surpluses and bond ratings, though, Gandhi was routinely the subject of harsh criticism and persistent questions.

His agency was ground zero for a $48 million embezzlement scheme —the largest in the District’s history — along with numerous other misdeeds by employees that ranged from fraudulently using disabled parking permits to lying on job applications.

The latter half of 2012 was especially brutal for Gandhi, who faced skeptical questions from lawmakers and reporters about hiring practices in his sprawling office and the assessments of commercial property values.

And the city’s $38 million lottery contract, which Gandhi’s office oversees and is now the subject of a federal investigation, emerged as a key issue that culminated in a contentious December council hearing in which Gandhi refused to answer questions about the matter.

The procurement process for that contract is also the subject of pending civil lawsuits.

But on Friday, city leaders were heaping praise on Gandhi, who migrated to the United States in 1965 and has published several volumes of poetry in Gujarati, the language of his native western India.

Gray hailed the CFO as an “exemplary steward of the District’s finances” and said he was “sorry to see him go.”

And D.C. Council Chairman Phil Mendelson cited Gandhi as the “primary reason” the District has seen its fiscal fortunes recover.

“As with any person who excels in his or her profession, Nat Gandhi has made the work look easy,” Mendelson said in a statement. “But anyone who looks closely will realize quickly that guiding the District’s fiscal health is work – hard work.”

And Councilman David Catania, who once lampooned Gandhi as the “chief fictional officer,” said he thanked the CFO for his service and wanted to “wish him well.”

Gandhi’s resignation will take effect on June 1, and city officials are expected to launch a wide-ranging search for the District’s next finance chief.

“We can also see this as an opportunity to find a successor who brings fresh eyes, continues the excellence and can lead us financially in the next decade,” Mendelson said.