PharMerica Corp.  (PMC) stock surged over 15% at Wednesday's market open as KKR & Co.  (KKR) and Walgreens Boots Alliance Inc.  (WBA) reached a deal to take the institutional pharmacy-services company private in a $1.4 billion deal.

KKR will control the new private company and Walgreens will be a minority investor, PharMerica said in a statement. PharMerica shareholders will receive $29.25 per share in cash, a 17% premium to Tuesday's closing price.

The company's board has approved the transaction, which includes $909.4 million in cash the assumption of $490 million in debt. The deal will close in early 2018 pending shareholder approval.

Walgreens' shares were down 38 cents, or less than a percent to $80.75 per share. 

The deal comes as Walgreens seeks to complete an acquisition of more than 2,000 Rite Aid Corp. (RAD) locations and after the company has already completed a handful of deals over the years. Walgreens Boots Alliance Inc. has acquired Liz Earle Beauty Co. Ltd. from Avon Products Inc. for $215.6 million (£140 million) in an all-cash transaction in January 2015.

PharMerica reported second quarter earnings in line with FactSet analyst expectations of 47 cents per share Wednesday. The company's stock has risen about 15% year-to-date.

The deal marks the end of a PharMerica as a long-speculated takeout target.

In August 2011, Omnicare Inc. (now part of CVS Health (CVS) ) submitted a $457 million bid, but was subsequently shot down by the Federal Trade Commission out of fear that the merger would induce higher drug prices.

"This is an opportunity to expand into a growing segment, and to do so through a national footprint," said Alex Gourlay, Walgreens Boots Alliance co-chief operating officer in a statement. "As the healthcare landscape and patients' needs continue to change, this is another way we can support quality, affordable patient care."

Formed back in Jan. 2007 from the merger of Kindred Healthcare Inc.'s (KND) pharmacy business with a subsidiary of AmerisourceBergen Corp. (ABC) , the Louisville, K.Y.-based company serves long-term care facilities, hospital pharmacy management services, and oncology pharmacy markets.

More of What's Trending on TheStreet:

More from Stocks

Micron and Other Chip Stocks Rally After U.S. Puts China Tariffs On Hold

Micron and Other Chip Stocks Rally After U.S. Puts China Tariffs On Hold

Dow Rises Sharply as U.S.-China Trade Tensions Thaw

Dow Rises Sharply as U.S.-China Trade Tensions Thaw

The Market Is Still Addicted to Stock Buybacks and It Could Prove Lethal

The Market Is Still Addicted to Stock Buybacks and It Could Prove Lethal

Attention 60 Minutes: Google Isn't the Only Big-Tech Monopoly

Attention 60 Minutes: Google Isn't the Only Big-Tech Monopoly

GE's $11.1 Billion Deal With Wabtec Should Have Warren Buffett Feeling Very Sad

GE's $11.1 Billion Deal With Wabtec Should Have Warren Buffett Feeling Very Sad