Drugstore operator CVS Health Corp (CVS.N) will buy Target Corp’s (TGT.N) pharmacies and clinics in a $1.9 billion deal that should help it bargain with drug makers for lower prices, while freeing Target from a costly business where it struggled to make a profit.

CVS, the second-largest U.S. drugstore operator with 7,800 stores, said on Monday it will acquire Target’s more than 1,660 pharmacies in 47 states with about $4 billion in annual sales. It will also acquire Target’s nearly 80 clinics.

Reuters The pharmacies will continue to be located within Target stores but carry the CVS brand.

The move was the CVS’ second large acquisition in as many months, coming on the heels of its $10.1 billion deal for healthcare services firm Omnicare Inc (OCR.N) in May.

The transaction will significantly expand the drugstore chain’s retail presence and should bolster its bargaining power with pharmaceutical companies.

“The healthcare industry is evolving rapidly,” CVS Chief Executive Larry Merlo said on a conference call. “In this environment, success is all about effectively managing costs, quality and access.”

For Target, the deal divests a business that was “modestly negative” in terms of profits. While Target will lose revenue, its sales, general and administrative costs will drop by $1 billion.

Target Chief Executive Brian Cornell said the move fits with the company’s focus on a handful of categories where it believes it can be most competitive including apparel, items for children and health and wellness-related goods. Target will continue to handle the sale of over-the-counter drugs.

Cornell, who has been remaking the retailer’s strategy since taking the helm in August, said the deal will allow it to focus resources on reviving its food business, for instance.

He also said it should bring more customers into Target stores. The companies hope CVS’ price advantages, including in generic drugs, will attract more customers to the pharmacies who then buy other items from Target.

“They bring scale, cost efficiency; they bring expertise that we just could not bring to a space that we were operating as a subscale player,” Cornell said of CVS.

CVS shares were up 0.7 percent at $102.88, while Target shares rose 1.3 percent to $80.51 in morning trading.

The two companies said the 80 Target clinics will be rebranded as MinuteClinics, as will the 20 additional clinics they plan to open within three years of the deal closing, expected near the end of 2015..

Target and CVS also said they plan to co-develop five to 10 small-format stores, potentially accelerating Target’s strategy of finding growth through smaller outlets in urban areas.

The deal will also affect both companies’ plans for share buybacks.

Target said it would likely use some of the expected $1.2 billion in after-tax proceeds for shares repurchases. It doubled its share buyback program to $10 billion last week.

In contrast, CVS cut its 2015 share repurchase program by $1 billion to $5 billion as a result of the transaction, which it will finance with debt. The move adds to the strain on its finances, already under pressure from the Omnicare deal.

CVS’ reduced buyback target led it to lower its 2015 and 2016 adjusted earnings forecast.