Coca-Cola now has no presence in the coffee market, and wants to use the deal to expand into the space.
Whitbread bought Costa in 1995 from founders Sergio and Bruno Costa and presently runs about 2,400 stores in the United Kingdom and some 1,400 around the world.
Shares of Whitbread jumped by 696p, or 17.3 per cent, to £47.16 after the market opened. It now has more than 2,400 United Kingdom coffee shops, as well as some 1,400 outlets in 31 overseas markets.
The announcement comes three days after Nespresso maker Nestle said it sealed a deal to market the products of United States coffee giant Starbucks around the world, outside of its cafes. "Costa gives us access to this market with a strong coffee platform".
In recent years, Whitbread has invested heavily in Costa's expansion overseas, but had been looking to siphon off the business to generate funds for the expansion and for its other business, the budget hotel chain Premier Inn.
Shares in Whibread surged nearly 20% on the news, adding more than £1bn to the group's stock market value, as analysts said the price was substantially higher than expected. At the time, it had 39 shops. "A significant majority" of the proceeds will be given to the shareholders, the firm added.
It has recently expanded into China after growth in Britain became harder to find in a market bursting with chains such as Starbucks, Caffe Nero and thousands of independent outlets.
Costa is owned by Whitbread, the British multinational hospitality company.
Nestle joined the trend of coffee giants taking aim at smaller niche producers, buying Blue Bottle Coffee and Chameleon Cold Brew.
JAB added the United Kingdom -based food-and-coffee chain Pret A Manger in a $2 billion deal earlier this year, following its past acquisitions of high-end coffee brands Peet's and Stumptown.
Italian coffee maker Illycaffe SpA has attracted interest from suitors including JAB and Nestle, but the family owners have so far rebuffed approaches, according to people familiar with the matter.
Buying Costa puts Coke in direct competition with Starbucks and several other global coffee brands.
Bankers from Rothschild advised Coke, while Whitbread used Goldman Sachs, Morgan Stanley and Deutsche Bank AG.