Valencia biophamaceutical firm MannKind Corp. has inked a deal for up to $160 million in debt financing from affiliates of New York healthcare investment company Deerfield Management Co. L.P., company officials said Monday.

MannKind will receive the money in four stages, at milestones in the development of its primary pipeline product, inhaled insulin drug Afrezza. The final payment will be given when the Food and Drug Administration approves the product.

“We are encouraged by Deerfield’s confidence in the potential of Afrezza,” said MannKind Chief Executive Alfred Mann in a statement.

The company went public in 2004 and has yet to introduce a drug to the market. Most income has come through secondary offerings and the backing of its founder, billionaire entrepreneur Mann.

In December, Mann converted more than $107 million debt owed to him by MannKind into 40 million shares and warrants to purchase another 30 million.

The company completed Phase III trials of the drug in patients with Type I and II diabetes last month, and plans to release the data later this summer. The trials are the last major hurdle before the company can ask the FDA for approval of the product, which it first did in 2011.

The study looked at the safety and effectiveness of the drug as administered to patients with Type II diabetes by the MedTone inhaler, the first model tested by MannKind, and a newer version, the Dreamboat inhaler. Both were compared to traditional injected insulin.

The trials were done at the request of the FDA, which called for more research in 2011 after MannKind had completed testing with the MedTone but then introduced the newer inhaler. The drug could be used to treat adults with Type I and Type II diabetes.

Shares gained 29 cents, or more than 4 percent, to close at $6.79 on the Nasdaq.