Coca-Cola announced Friday that it will acquire the British coffee chain Costa, the second-largest coffee house in the world, for about $5.1 billion as soda companies reconfigure their businesses while consumers shift away from sugary, carbonated drinks.

The Atlanta-based beverage giant described the proposed deal as a necessary entryway to the expanding global coffee market. “Hot beverages is one of the few segments of the total beverage landscape where Coca-Cola does not have a global brand," James Quincey, the president and chief executive of Coca-Cola, said in a news release announcing the acquisition. The deal also offers Coca-Cola an expanded retail footprint in Europe and China.

U.K.-based Costa serves its drinks in more than 30 countries in Asia, the Middle East, Africa and Europe but does not have a presence in the United States. The majority of its nearly 4,000 stores are in Britain, where the company generates most of its sales.

Experts say the deal reinforces an industry trend away from sodas, owing to both changing generational tastes and growing health concerns tied to the consumption of sweetened beverages.

"Coca-Cola faces the long-term problem that people are moving away from soda and towards healthier or more functional drinks like coffee," said Jonny Forsyth, global drinks analyst at Mintel. "Twenty years ago, people would have a coffee in the morning and a coke in the afternoon. Today's consumers are now more likely to have a hot coffee in the morning and a cold coffee in the afternoon."

While U.S. consumers are the primary drivers behind the shift, customers in Asia, Latin America and the Middle East are also starting to seek their jolt of caffeine from another source, he said.

Coca-Cola's planned purchase follows Nestlé's $7 billion licensing deal to sell Starbucks coffee in grocery stores around the world to revitalize its hot-drink business, which experts say has stagnated, especially with younger customers.

Quincey said in a call with investors Friday that millennials are willing to spend their money on drinks but are looking for more diverse options. The deal would bolster Coca-Cola's efforts to become a "total beverage company," according to investor presentation materials, moving the business from its traditional reliance on soft drinks, such as its namesake Coca-Cola and Sprite.

"When I walk into the classroom and look out at students I am very unlikely to see any of them with a Big Gulp filled with soda," said Erik Gordon, a professor at the University of Michigan’s Ross School of Business. "The two things you are likely to see are a bottle of water or a cup of coffee."

Gordon said that Coca-Cola and rival PepsiCo, which plans to buy the do-it-yourself seltzer company SodasStream, are fortifying their product lines to avoid the fate of another iconic American brand: Campbell's Soup. Campbell's announced Thursday that it is selling off its international operations as the company wrestles with declining sales and a consumer base hungry for healthier alternatives.

“Pepsi and Coke don't want to end up having their fate ride on their traditional core product when that product is becoming less attractive every year," he said. "They don't want to end up half the company they used to be.”

But Gordon also questioned the soundness of Coca-Cola's acquisition. "What's surprising to me is that buying Costa brings them into the storefront retail business, which is a difficult business and is a business that Coke has no history, no skills in." He noted that spending billions on British coffee shops would not directly play into Coca-Cola's greatest strength, its hyperefficient and far-flung distribution system.

Quincey said that Coca-Cola would retain Costa's retail management. And he acknowledged that running the new coffee chain would effectively be Coke's first direct-to-consumer business. "We'll use the retail stores to build the brand and drive the experience," he said during the call.

Coca-Cola plans to use its existing global infrastructure to expand Costa's business lines, which include retail outlets, vending machines and coffee for use at home. Quincey said that for the U.S. market, Coca-Cola's first push to deliver Costa's coffee would likely come through food services and vending with existing customers, such as the sale of coffee pods, beans or pre-made beverages, rather than opening retail coffee shops, an already crowded space.

Alison Brittain, the chief executive of Costa's parent company, Whitbread, said the sale will please shareholders because they'll see funds returned to them, it will contribute to the company's pension fund, and it will help pay off company debt, she told CNBC in an interview Friday. Whitbread shares climbed more than 16 percent Friday on the London Stock Exchange.

The proposed deal is expected to close at the end of summer 2019, Coca-Cola said, if it gains regulatory approval in the European Union and China.

Coca-Cola shares were slightly down Friday in afternoon trading.