Pfizer Inc. is combining its business line of older blockbuster medicines such as Lipitor and Viagra with generic drugmaker Mylan NV, in a deal that will reshape the brand-name and off-patent pharmaceutical industries.

Under the all-stock deal, a “Reverse Morris Trust” transaction, Mylan investors would get 43% of the new entity and Pfizer investors the rest. The new publicly traded company will have sales of about $19 billion to $20 billion in 2020, the drugmakers said in a statement.

The deal will spin out Pfizer’s Upjohn unit, then combine it with Mylan. The new company will have about $24.5 billion in debt and an investment-grade credit rating, the companies said. The transaction is expected to close in mid-2020, and the company will be renamed.

The deal will provide answers to questions both companies have faced.

For New York-based Pfizer, it provides a pocket to place profitable yet older products like cholesterol pill Lipitor and erectile dysfunction drug Viagra, which still fetch hundreds of millions of dollars in global sales but aren’t key to the company’s growth.

Mylan has struggled in the face of declining prices for generic drugs, manufacturing issues at a key plant and legal questions about the company’s alleged involvement in a price-fixing conspiracy with other drugmakers.

Michael Goettler, who runs Pfizer’s off-patent drug unit, will become chief executive officer of the combined company; Mylan Chairman Robert J. Coury will be executive chairman. Current Mylan CEO Heather Bresch will depart after the deal closes, while Mylan Chief Financial Officer Ken Parks will also leave.

While Pfizer shareholders will end up with a larger slice of the new company’s equity, Mylan will have tighter control of its board. With Coury as executive chairman, Mylan will also get to name eight other board members. Pfizer will name three. Goettler will also get a seat, for a total of 13 members.

Mylan executives met in New York last week to discuss the accord, and no one else is likely to bid for the company, according to a person familiar with the transaction. Mylan, whose shares have fallen almost 50% in the past year, has a market value of $9.5 billion. Pfizer is up 12% in the same period and is worth $240 billion.

The business would be based in the U.S., removing the Dutch governance structure that has frustrated some Mylan investors and is essentially a takeover defense.

Earlier, Mylan reported earnings that beat analyst estimates. Second-quarter adjusted earnings were $1.03 a share, topping the 95 cents average of Wall Street’s estimates compiled by Bloomberg. The company reaffirmed its 2019 forecast of adjusted earnings of $3.80 to $4.80 a share and revenue of $11.5 billion to $12.5 billion.

Pfizer posted second-quarter adjusted earnings per share of 80 cents, beating the average Wall Street estimate of 75 cents. But it also lowered guidance for the year to $2.76 to $2.86 a share from $2.83 to $2.93, taking into account the formation of a consumer joint-venture with GlaxoSmithKline Plc and the anticipated completion of its acquisition of Array BioPharma Inc.

Sales in the second quarter totaled $13.2 billion, a 2% decline from a year prior. The drugmaker’s off-patent business Upjohn saw sales fall 11% year-over-year, to $2.8 billion from $3.1 billion.

The generic-drug industry has been under increasing pressure in recent years as competition drives prices lower and lower. In some cases, companies have been able to charge no more than the cost of production for certain medications.

That has also resulted in problems for consumers as some drugmakers elect to abandon medications that are no longer profitable, leading to shortages and other imbalances in the marketplace.

At the same time, giant pharmaceutical companies including Pfizer have been focusing more on developing innovative treatments for cancer and rare diseases. Pfizer has said that it’s trying to increase the pace of its own drug development and has been looking for ways to replenish its pipeline of potential blockbusters. In recent years, it has spun off the animal-health business and agreed to merge the consumer health arm into a new venture with GlaxoSmithKline Plc.

Mylan has also faced questions about its popular EpiPen allergy auto-injector, which many consumers have said they have had a hard time finding in pharmacies. The company and the Food and Drug Administration earlier this year extended the expiration dates of some devices in order to manage the shortfall. A Pfizer unit called Meridian Medical Technologies manufactures the EpiPen for Mylan. The Meridian business has formed part of the negotiations on the deal, a person familiar with the matter said.