(Adds upcoming court date in paragraph 2, details on the settlement and Endo's bankruptcy in paragraphs 4-7)

NEW YORK, Feb 29 (Reuters) - Bankrupt drugmaker Endo International will pay up to $465 million to settle the federal government's law enforcement, tax, and healthcare cost claims, the U.S. Department of Justice said on Thursday.

The settlement removes Endo's largest obstacle to completing its plan to sell its assets to its lenders in bankruptcy. Endo will ask a U.S. bankruptcy judge to approve the sale and allow the company to emerge from bankruptcy at a March 19 court hearing, the DOJ added.

Endo filed for bankruptcy in August 2022 to address its $8 billion debt and thousands of lawsuits over its alleged role in the U.S. opioid epidemic. The company has agreed to pay about $600 million in settlements to states and people afflicted by the opioid crisis and to stop promoting opioids to prescribers.

Damian Williams, U.S. Attorney for the Southern District of New York, said on Thursday that bankruptcy is not a "free pass to evade responsibility for criminal misconduct, civil fraud, or taxes."

The DOJ settlement ensures that Endo takes responsibility for its past misconduct, and it preserves Endo's previous agreements to fund state and local opioid addiction treatment programs and make payments to individuals harmed by the opioid epidemic, Williams said.

Endo has agreed to pay the government $364.9 million over 10 years, plus a contingent payment of up to $100 million, depending on how well its business performs after its exit from bankruptcy. The settlement allows Endo to opt for a lower, one-time payment of $200 million immediately upon its exit from bankruptcy.

The settlement resolves over $7 billion in claims that the DOJ had asserted against Endo for purported tax debts, a DOJ criminal investigation into Endo's opioid marketing, and the federal government's possible overpayment for Endo medications.

Endo subsidiary Endo Health Solutions Inc (EHSI) also agreed to plead guilty to a misdemeanor over its past marketing of the opioid drug Opana ER. EHSI, which stopped selling Opana ER in 2017, will plead guilty to violating the Federal Food, Drug and Cosmetic Act (FDCA) by selling misbranded drugs.

Before filing for bankruptcy, Endo had paid $242 million to settle opioid lawsuits, reaching deals with the eight U.S. states. It still faced over 3,100 other opioid lawsuits, and had spent about $344 million on opioid defense costs, court filings showed. (Reporting by Dietrich Knauth; Editing by Richard Chang and Alexia Garamfalvi)