Coca-Cola will spend $2.15 billion in exchange for a 16.7 percent stake in energy drink maker Monster Beverages. The deal will include some swapping of ownership in certain products for both companies.

Coca-Cola will deliver a cash payment totaling $2.15 billion to Monster. Monster shares soared in after-hours trading by over 35 percent. Coke shares also rose on the news, up 1.3 percent in after hours trading.

Coke will have to turn over its energy drink businesses to Monster. Coke has NOS and Burn energy drinks and several others. Also as terms of the deal, Monster will transfer its non-energy businesses to Coke. Monster makes Hansen's Natural Sodas and other non-energy businesses.

"Our equity investment in Monster is a capital efficient way to bolster our participation in the fast-growing and attractive global energy drinks category," Coke CEO Muhtar Kent said in a statement.

Analysts are appluading the deal saying it's a good thing for both companies.

"They're both winners in this one. Coke certainly needs growth..." Bill Chappell, a managing director at SunTrust Robinson Humphrey, said in a CNBC interview.

Chappell added that Coke's own energy drinks have been "nonstarters around the world."

By partnering with Monster and improving its energy drink business, Coca-Cola is definitely confirming that energy drinks are a key market that they want to focus on.

The deal between Coke and Monster is expected to close either later this year or early next year.