Coca-Cola has agreed to buy coffee chain Costa for $5.1 billion, taking on Starbucks in the booming global coffee market and extending its push into healthier drinks.

The purchase from Britain's Whitbread of Costa's almost 4,000 outlets thrusts the world's biggest soda company into one of the few bright spots in the sluggish packaged food and drinks sector.

Paying about $1.3 billion more than some analysts had expected, Coke will use its distribution network to supercharge Costa's expansion as it chases current coffee chain market leader Starbucks and its almost 29,000 stores across 77 markets.

Beyond coffee shops, Coca-Cola CEO James Quincey, himself a Briton familiar with the U.K. brand, said Costa would provide an important growth platform ranging from beans to bottled drinks in what is one of the world's fastest-growing drink categories, growing around 6 percent a year. Coke sells Georgia coffee in Japan, but wanted a bigger platform.

"Coca-Cola doesn't have a broad, global portfolio in this growing category," Quincey said in a blog post highlighting Costa's retail footprint, roastery, supply chain and Costa Express vending system, which the company plans to expand.

But Coca-Cola will face a fight, as rivals are also bulking up in a fragmented market, keen to attract young people prepared to pay out for barista-made drinks and developing tastes for ever more exotic coffees.

Nestle, the market leader in packaged coffee, for example, has sealed a $7 billion licensing deal for Starbucks' retail business, while Europe's billionaire Reimann clan has built the JAB empire spanning coffee brands such as Kenco, Douwe Egberts and soft-drink maker Dr Pepper Snapple.

Operating a retail chain marks a new challenge for 132-year-old Atlanta-based Coca-Cola, which mostly sells soft drink concentrates to a network of franchised bottlers.

Other packaged goods firms with restaurant footprints include Nestle, with its stake in upscale coffee chain Blue Bottle, and Unilever with gelato chain Grom.

In the key U.S. market, an expansion of Costa shops into the country would be a threat for Starbucks, McDonalds and JAB, which owns a string of chains including Peet's and Caribou.

Meanwhile, a roll-out of canned or bottled coffee drinks through Coke's bottling system could upset the dominance of a joint venture between Starbucks and PepsiCo.

The purchase of the biggest coffee chain behind Starbucks adds to Coca-Cola's drive to diversify away from fizzy drinks and expand its options for increasingly health-conscious consumers, after countries started introducing sugar taxes.