JTA – Chabad has purchased a building in midtown Manhattan for $42 million.

In its announcement, Chabad said it had been renting the 12-story, 60,000-sq.-ft. building at 509 Fifth Avenue for the past 16 years before it bought it on Thursday. The building has a synagogue, offers programming and oversees the activities of seven Chabad centers in Manhattan. It also includes vacant space.

“We are extraordinarily grateful to God for this enormous blessing,” Rabbi Joshua Metzger, executive director of Chabad of Midtown Manhattan, said in a statement. “This record-breaking acquisition presents enormous opportunities and an awesome responsibility to ensure that all of our Jewish brethren in the heart of one of the largest cities of the world are cared for and inspired.”

In April 2010, the New York Post reported, Metzger filed a $30 million lawsuit in New York State Supreme Court against real estate investors David Werner and Amram Kass. Metzger alleged that he discussed with them his desire to buy the building but was subsequently cut out from its purchase. The suit also was filed against the building’s then-owner, 509 Fifth Avenue Associates Owner, which includes Norman Sturner of Murray Hill Properties, the Post reported.

Werner, Metzger alleged, was a matchmaker between seller Joseph Moinian and Sturner, who bought the structure for $32 million, according to the Post.

In January 2012, Sturner’s ownership group filed a $9 million suit against several groups, including the Chai Foundation – a Chabad operation — and Metzger. It alleged that Metzger had not paid rent and was in the process of being evicted when another company had signed the contract to buy the building for $39 million – a deal that fell through in December 2011, according to the Post.