NEW YORK, June 28 (Reuters) - A U.S. bankruptcy judge on Friday approved Rite Aid's restructuring plan, allowing the pharmacy chain to cut $2 billion in debt and turn over control of the company to a group of its lenders.

U.S. Bankruptcy Judge Michael Kaplan approved Rite Aid's bankruptcy plan at a court hearing in Trenton, New Jersey, saying that the restructuring had saved the company from having to shut down and liquidate operations.

Rite Aid used its bankruptcy to close hundreds of stores, sell its pharmacy benefit company Elixir, and negotiate settlements with its lenders, drug distribution partner McKesson and other creditors, including individuals and governments that have sued it for allegedly contributing to the deadly U.S. opioid epidemic.

Rite Aid, which had over 2,000 stores when it filed for bankruptcy in October, will emerge from bankruptcy with about 1,300 remaining locations. (Reporting by Dietrich Knauth Editing by Chris Reese and Leslie Adler)