Keurig Dr Pepper Inc. said it has agreed to buy a 30% stake in Nutrabolt, the company behind energy drinks such as C4 and Xtend, for $863 million in a deal that provides an exit for private-equity backer MidOcean Partners after investing about eight years ago.

Publicly traded Keurig Dr Pepper has agreed to sell and distribute C4 Energy in the majority of its company-owned direct store distribution territories, which is expected to meaningfully increase availability and penetration for the brand. Nutrabolt will continue to distribute C4 Energy through specialty, health club and fitness channels, the companies said.

The cash investment from Keurig, expected to close this month, would make the Burlington, Mass.-based company Nutrabolt’s second-largest investor, behind only Doss Cunningham, its founder, chairman and chief executive. Keurig would get preferred equity in privately held Nutrabolt with a 5% annual coupon paid in cash or in-kind.

Keurig would have the opportunity to earn more equity based on in-market execution and would get representation on Nutrabolt’s board of directors.

The deal puts the value of Austin, Texas-based Nutrabolt at at least $2.87 billion, based on Keurig’s roughly 30% stake. Nutrabolt is expected to post sales of at least $650 million next year, the companies said.

Midmarket-focused MidOcean initially invested in Nutrabolt in July 2014, backing the company alongside consumer-packaged goods veterans Brian Goldberg and Clayton Christopher. During MidOcean’s investment the company acquired sports nutrition brand Scivation Inc. in 2017, a deal that brought the Xtend brand into the Nutrabolt portfolio. 

With MidOcean’s backing, the company nearly quadrupled its revenue, according to a MidOcean press release. 

New York-based MidOcean managed about $4.1 billion in regulatory assets across its private-equity funds, as of Dec. 31, 2021, according to the private-equity unit’s latest registered investment adviser filing. As of July 2022, the firm had raised at least $1.4 billion for its sixth midmarket private-equity fund, a separate regulatory filing indicates. MidOcean’s credit investment business managed some $8.9 billion in regulatory assets as of the end of 2021, a separate registered investment adviser filing indicates.

Write to Will Feuer at Will.Feuer@wsj.com Laura Kreutzer at Laura.Kreutzer@WSJ.com