Trying to gain ground in the energy drink market, Coca-Cola has bought a 16.7 percent stake in Monster for $2.15 billion.

As part of the deal, Monster will take over Coke’s small energy-drink business, while Coke will absorb the former’s nonenergy drink brands.

Coke said it also has the option to boost its stake in Monster to 25 percent.

Atlanta-based Coke is under pressure to find new products as its core soft drink business struggles in North America, where concerns about the effect of sugary beverages on waistlines and health have flattened soda sales the past few years.

The deal gives Coke a stronger position in the robust and growing energy category. Coke’s own entrants — including NOS and Full Throttle — have lagged compared to Monster and Red Bull.

“This is a big and important deal for Coke,” said John Sicher, editor and publisher of Beverage Digest. “Monster, by volume, leads the energy drink business in the U.S. Last year, it had a 37.9 share and outperformed the energy drink category. It is an important and powerful brand.”

Reports of discussions between Coke and Corona, California-based Monster started more than two years ago, with Coke initially denying talks.

The brand-swap deal “generates scale and better opportunity of customer impact points,” Coke Chief Executive Officer Muhtar Kent said.