CVS Health Corp. agreed to buy Aetna Inc. for about $69 billion in cash and stock in a move to transform the pharmacy company and capture more of what consumers spend on health care.​

Aetna stockholders are to receive $207 per share—$145 in cash and 0.8378 of a CVS share, or $62, in stock, the companies announced Sunday. That represents a premium of about 29% to where Aetna shares were trading before The Wall Street Journal reported that the companies were in talks in October.

The...