CVS and Omnicare are both Medicare Part D players. (AP Photo/M. Spencer Green)

(Bloomberg) — CVS Health Corp. (NYSE:CVS), the biggest U.S. retailer of prescription drugs, agreed to acquire nursing-home pharmacy Omnicare Inc. for a total enterprise value of $12.7 billion.

See also: Omnicare at almost $10 billion still worth it for CVS

CVS will pay $98 per share in cash, the companies said in a statement on Thursday. Omnicare, with a market value of about $9.2 billion, hired advisers to explore a sale earlier this year. The deal includes about $2.3 billion in debt.

Omnicare delivers drugs and helps senior-living facilities manage residents’ medications. CVS is the nation’s second-largest pharmacy benefits manager, handling drug plans for health insurers and employers. In its most recent quarter, growth in sales from that business far outpaced the company’s retail division.

“CVS Health will significantly expand its ability to dispense prescriptions in assisted living and long term care facilities, serving the senior patient population” with the transaction, it said.

Both companies are big in Medicare Part D, a federal program that subsidizes medicine for retirees, Charles Rhyee, a New York-based analyst for Cowen Group Inc., said in an interview last month. Omnicare also drew interest from industry leader Express Scripts Holding Co., people with knowledge of the matter said last month.

Board approvals

The boards of both CVS and Omnicare approved the transaction, which holders of Omnicare’s common stock must also clear, according to the statement. It’s expected to close, pending regulatory approval, at the end of the year and boost CVS’s adjusted earnings per share by 20 cents next year, CVS said.

Demand for pharmacy services is rising as patients, insurers and companies look for ways to manage costs with drug prices increasing. Pharmacy-services providers are combining to gain a bigger piece of the growing market.

UnitedHealth Group Inc. (NYSE:UNH) said in March that it would buy Catamaran Corp. in a $12.8 billion deal to create a third-place competitor. That deal came on the heels of Rite Aid Corp.’s agreement to buy pharmacy benefits manager EnvisionRx for about $2 billion.

See also: UnitedHealth pays $12.8 billion for Catamaran’s drug clients and Rite Aid buys TPG’s EnvisionRx for $2 billion

Express Scripts became the biggest pharmacy-benefits management company after purchasing Medco Health Solutions Inc. three years ago for $34 billion including net debt.

Barclays P.L.C. and Evercore Partners Inc. acted as financial advisers and investment bankers to CVS. Sullivan & Cromwell L.L.P. advised the company on legal matters and Dechert L.L.P. on antitrust questions.

Bank of America Merrill Lynch and Centerview Partners were financial advisors to Omnicare, and White & Case L.L.P. its legal counsel.

Copyright 2018 Bloomberg. All rights reserved. This material may not be published, broadcast, rewritten, or redistributed.