AbbVie Inc. has agreed to pay $63 billion for rival drugmaker Allergan Plc, the latest huge merger in a pharmaceutical sector rapidly being reshaped by deals.

Allergan will get $188.24 a share in cash and stock, a 45% premium to its closing price on Monday. Allergan shares rose 31% to $170.25 in premarket trading in the U.S. early Tuesday. AbbVie was down 8.2% to $72.

The takeover offers a solution to long-standing challenges both companies have grappled with. AbbVie finally gets a set of products big enough to diversify its revenue from Humira, the top-selling rheumatoid arthritis injection that dominates its sales. And Allergan, which is heavily reliant on Botox, will will get a profitable exit for shareholders after a four-year slide.

“This is a good alternative for Allergan versus the current share price,” said David Maris, an analyst with Wells Fargo.

The expected cost savings from the deal will buy both companies more time, but not solve their long-term issues. Both of their blockbuster drugs have begun to face pressure: AbbVie may be nearing the limits of how far it can raise Humira’s price as cheaper competitors come to market, a problem Allergan is already facing as more rivals to Botox emerge. Neither company has acquired or developed a major new product to replace the sales generated by their biggest hits.

The deal is evidence that even the world’s biggest drugmakers believe they can get even bigger. In January, Bristol-Myers Squibb Co. announced a $74 billion deal for Celgene Corp., and Japan’s Takeda Pharmaceutical Co. earlier this year completed a $62 billion takeover of Shire Plc. A combined AbbVie and Allergan will have sales of about $48 billion, the companies said in a statement, making it one of the biggest in the industry.

The combinations have begun to attract the notice of antitrust authorities. On Monday, Bristol-Myers said it had agreed to divest one of Celgene’s top products, the psoriasis pill Otezla, in order to appease regulators at the U.S. Federal Trade Commission. While there are few major areas of overlap between Allergan and AbbVie, the deal is almost certain to get a careful look from regulators.

The deal will also return Allergan to the U.S., at least for tax purposes. While the company is run from New Jersey, it moved its domicile to Dublin in 2015 via another merger, partly to take advantage of lower corporate rates abroad. The 2017 U.S. tax overhaul cut corporate levies to 21% from 35%, which reduced incentives for companies to relocate overseas.

AbbVie currently pays far less in tax than that, however, and has said it will have an effective rate of 9% this year. It has projected its effective rate will rise to 13%.

Saunders had spent months turning over plans for Allergan as the drugmaker’s stock price dropped from a 2015 peak of almost $340. Those options included selling off the company’s gastrointestinal drugs or women’s health unit, which would have left it more focused on its profitable medical aesthetics line that includes the wrinkle treatment Botox.

AbbVie said it expects at least $2 billion in annual pretax synergies and other cost reductions in year three of the deal. About half of that will come from optimizing the research and early-stage portfolio of products and cuts in overlapping R&D resources, while the rest will come from sales, general and administrative expenses and costs for manufacturing, supply chain and procurement.

Allergan holders will receive 0.8660 AbbVie shares and $120.30 in cash for each share they hold. AbbVie will take on Allergan’s debt, which totaled about $24 billion at the end of the first quarter.

Two Allergan directors, including Chief Executive Officer Brent Saunders, will join AbbVie’s board after the purchase is completed, according to the statement.

The deal is expected to close in early 2020, the companies said.

Morgan Stanley & Co. acted as AbbVie’s financial adviser and Kirkland & Ellis LLP and McCann FitzGerald were legal advisers. JPMorgan Chase & Co. was AbbVie’s financial adviser, and Wachtell, Lipton, Rosen & Katz and Arthur Cox gave legal advice.