Elanco Animal Health agreed to buy Bayer’s veterinary drugs unit in a cash and stock deal valued at $7.6 billion, creating the second-largest maker of medicines for pets and livestock and expanding Elanco’s reach online.

Merck & Co. is paying about $2.4 billion to acquire all outstanding shares of Antelliq Group, and is also assuming the digital technology company’s debt of $1.3 billion.