Walgreens Boots Alliance Inc. has agreed to invest $5.2 billion in primary-care provider VillageMD, doubling its stake in the company to 63%. 

The deal will increase the number of primary-care practices located at Walgreens chain stores to 1,000 by 2027, with more than half the practices located in underserved communities, the companies said in a joint statement.

Drugstores are under pressure to increase their offerings as e-commerce firms including retail giant Amazon.com Inc. make inroads into the pharmacy sphere. Walgreens is raising its profile in value-based primary care, a quickly growing segment of the health-care market worth about $1 trillion, according to the statement.

The company announced an investment of $1 billion in closely held VillageMD early last year, with a goal of building 600 to 700 pharmacy-located practices. The partners said in January Walgreens had accelerated its investment.

Founded in 2013, VillageMD is planning to go public, Bloomberg reported in April, citing people familiar with the matter. The initial public offering could raise as much as $1 billion and value the company at up to $10 billion, one of the people said then.

The IPO is now expected early next year, with Walgreens remaining the majority shareholder, James Kehoe, the company’s chief financial officer, said on a call with investors.

Walgreens separately released quarterly results today that beat analysts’ estimates. Profit for the fiscal fourth quarter was $1.17 a share, with sales of $34.3 billion, according to a statement. Wall Street had expected adjusted earnings of $1 a share and revenue of $33.1 billion, according to estimates compiled by Bloomberg.

Adjusted earnings per share will grow at about 4% over the next three years on a compounded annual basis, Kehoe said in a presentation. The growth rate will be influenced by investments and lower vaccination rates in the 2022 fiscal year, the CFO said.