Rite Aid Corp. agreed to buy EnvisionRx, a pharmacy-benefits manager owned by private-equity firm TPG, for about $2 billion, opening a new front in its competition with CVS Health Corp.

Rite Aid will pay about $1.8 billion in cash and $200 million in shares, the companies said in a statement today. EnvisionRx will have revenue this year about $5 billion and earnings before interest, tax, depreciation and amortization of $150 million to $160 million, they said.

With the purchase, Camp Hill, Pennsylvania-based Rite Aid is shifting toward offering services that help insurers and large employers provide drug coverage -- an industry where CVS is already the second-biggest competitor behind Express Scripts Holding Co. Rite Aid operates 4,569 pharmacies in the U.S., compared with CVS’s 7,800.

“With the addition of EnvisionRx, we will create a compelling pharmacy offering across retail, specialty and mail- order channels, enabling us to deliver cost-effective solutions to employers and health plans,” said John Standley, Rite Aid’s chairman and chief executive officer.

The acquisition helps Rite Aid expand beyond the slower- growing retail business, where its sales grew 0.5 percent last year to $25.5 billion. CVS’s benefits-managing unit, acquired in 2007, had revenue growth of 16 percent last year to $88.4 billion.

Rite Aid jumped 5 percent in early trading to $7.95. Through Tuesday, the shares had climbed 32 percent in the past year.

Benefit managers have gained prominence in the health-care industry by helping their clients extract discounts from drug companies for expensive medicine, like Gilead Sciences Inc.’s $1,000-a-day hepatitis treatment Sovaldi. Gilead’s discounts for hepatitis C drugs will climb to an average of 46 percent this year from 22 percent in 2014, the drugmaker said last week.

Citigroup Inc. served as financial adviser to Rite Aid and Skadden, Arps, Slate, Meagher & Flom LLP was the company’s legal adviser. JPMorgan Chase & Co. advised EnvisionRx, and Cleary Gottlieb Steen & Hamilton LLP acted as its legal counsel.

In another pharmacy expansion deal, Guardian Pharmacy of Atlanta bought two long-term care pharmacies in September.