Candy giant Mars Inc., facing a slowdown in packaged food, is making a bigger bet on a booming industry: pet care.

The maker of M&Ms and Snickers agreed to buy the animal-hospital chain VCA Inc. (Nasdaq: WOOF) for about $7.7 billion on Monday -- not including debt -- expanding on its existing veterinary-care business. Mars will pay $93 a share in cash, a 31 percent premium to VCA’s closing price of $70.77 on Friday.

Giant companies like Mars aren't the only buyers interested in the pet industry. Private equity firms and strategic buyers have shown their fondness for the subsector as the industry presents recurring costs for pet owners, and subsequently recurring revenues for businesses. Recently, rural-lifestyle-store chain Tractor Supply Co. (Nasdaq: TSCO) purchased pet food maker Petsense LLC in a $116 million deal. In 2015, pet brands Worldwise and Quaker Pet Group merged to acquire more; and J.M. Smucker Co. purchased Meow Mix and Milk-Bone owner Big Heart Pet Brands for approximatley $3.2 billion.

The VCA acquisition turns Mars into a dominant company in corporate-owned pet hospitals, an area that’s exploded in recent years -- helped by Americans treating their pets more like family members. It also could help bolster Mars’s current pet brands, including Pedigree and Whiskas. At a time when human food isn’t growing as quickly, the deal may make more sense for Mars than buying another snack business, said Ken Shea, an analyst at Bloomberg Intelligence.

“They see growth and they see diversity,” he said. “Why double down on food when it’s not growing that fast?”

The total value for the deal is about $9.1 billion, including $1.4 billion in outstanding debt. Shares of VCA, which trade under the ticker WOOF, surged as much as 29 percent to $91.03 on Monday after the transaction was announced.

Closely held Mars had already been building out its pet business, including both food and hospital care. The company owns Banfield Pet Hospital and BluePearl Veterinary Partners, and it’s acquired pet-food brands from Procter & Gamble Co. VCA, meanwhile, operates almost 800 animal hospitals in the U.S. and Canada.

The deal combines the top two veterinary hospital chains, but isn’t expected to run into regulatory challenges because it would represent less than 10 percent of the North American market, according to a research note from Stifel Nicolaus & Co.

The deeper push into the pet business by Mars comes as large packaged-food companies are struggling with flagging sales. Changing consumer tastes, particularly a desire for less processed foods, has made it difficult for the companies that have dominated grocery-store shelves. Efforts to reduce sugar intake have struck an additional blow to candy makers such as Mars. That’s added pressure to diversify their portfolios.

Spending on pets has surged in the U.S., fueled by the “humanization” of dogs and cats. Americans spent $35 billion on veterinary care in 2015. VCA, a pioneer in the field, has grown by buying up hundreds of veterinary hospitals -- an approach that’s now being adopted by rival companies.

And with an expanding presence in animal hospitals, Mars will have an opportunity to use the facilities to sell more of its pet foods, according to Shea.

“It’s a fast-growing industry and they obviously see an opportunity for that synergy,” he said.

Read more: The rise of corporate control over pet care

Mars, based in McLean, Virginia, expects the VCA deal to be completed in the third quarter. Morgan Stanley and BDT & Co. provided financial advice to Mars, while legal advisers included Skadden, Arps, Slate, Meagher & Flom LLP, Simpson Thacher & Bartlett LLP and McDermott Will & Emery LLP.

Barclays Plc advised VCA, and the company’s legal advisers were Akin Gump Strauss Hauer & Feld LLP and Potter Anderson Corroon LLP.

“VCA is a leader across pet health care and the opportunity we see together -- for pets, pet owners, veterinarians and other pet-care providers -- is tremendous,” Mars Chief Executive Officer Grant Reid said in a statement.

Additional reporting by Kamaron Leach, Mergers & Acquisitions