"This acquisition marks a major milestone on our path towards global leadership in the attractive non-prescription medicines business," Bayer's chief executive, Marijn Dekkers, said in a statement on Tuesday.
Merck, which is selling non-prescription brands such as the MiraLAX laxative and Afrin cold remedy, said it expects after-tax proceeds of between $8 billion and $9 billion from the sale, which is expected to close in the second half of 2014.
The transaction, the largest in the German healthcare industry since Bayer bought rival Schering for 17 billion euros (13.9 billion pounds) in 2006, will make Bayer the world's second-biggest consumer healthcare company, as it seeks to make better use of its distribution network and sales force.
"We can take these products and market them more forcefully than Merck has been able to do so far," Dekkers said in a conference call with analysts.
Bayer, the inventor of aspirin and maker of Bepanthen skin care products and Canesten antifungal creams, has repeatedly said it wants to take the top spot in the rankings.
Drug makers have embarked on a major reshuffling of their business portfolios. Novartis NOVN.VX and GlaxoSmithKline (GSK) last month agreed to trade more than $20 billion worth of assets, while AstraZeneca is fighting off a $106 billion takeover approach from Pfizer.
Meanwhile companies including France's Sanofi, Merck & Co and Abbott are looking at selling off mature drugs that have lost patent protection.
OTC drugs units carry far lower margins than prescription drugs businesses but many drug majors regard them as attractive complements due to the stable stream of cash they can generate.
They also require less spending on research and development and can be less exposed to the loss of patent protection where consumers remain loyal to a brand even when cheap copies become available.
But Reckitt Benckiser Group, one of the final contenders in Merck's auction, said on April 30 it was no longer in active talks to buy the Merck business, leaving Bayer in pole position.
Bayer also edged out other rival bidders, including Procter & Gamble Co, Boehringer Ingelheim, Novartis and Sanofi , people familiar with the matter have said.
J&J commands about 4 percent of the consumer health market - worth nearly $200 billion at the retail level.
Merck & Co has around 1 percent with brands including Dr Scholl foot care, Coppertone sunscreen and Claritin allergy medicine.
The fragmented OTC industry is consolidating fast. Novartis and GSK will form a joint venture in consumer healthcare as part of their agreement last month.
That deal is set to elevate the combined group, with $9.5 billion in sales, to the top of the global consumer health ranking, overtaking Johnson & Johnson and Bayer.
But Bayer said the Merck deal will put it back on the second rung, with $7.4 billion in combined sales.
J&J's consumer unit has $14.7 billion but market observers exclude many of its products, such as Listerine mouth wash, from their analysis of the OTC market.
With Bayer paying 6.5 times 2013 revenue and 21 times earnings before interest, taxes, depreciation and amortisation (EBITDA), analysts at Deutsche Bank said the price tag may seem "eye-watering" at first sight.
"The deal works both strategically and financially, and creates value (albeit to a modest degree)," the analysts said, adding it reduces volatility in the Bayer business and provides a predictable cash flow.
Bayer's enlarged consumer care unit will account for about 13 percent of group sales, up from 10 percent now.
Bayer's shares closed 0.9 percent lower at 99.07 euros, while the STOXX Europe 600 health care index .SXDP slipped 0.4 percent.
Reuters first reported last month that Bayer and Reckitt had emerged as frontrunners in the auction with each initially offering roughly $13.5 billion.
In addition, Bayer agreed to sell to Merck some rights to its Adempas drug against high blood pressure in the lung and other experimental cardiovascular drugs, saying it needed a marketing partner.
As part of that alliance, Merck will pay up to $2.1 billion, including $1.1 billion in milestone payments contingent on development achievements.
Bayer said it plans to finance the OTC acquisition with a bridge loan facility provided by Bank of America Merrill Lynch, BNP Paribas and Mizuho, which will be syndicated to a larger group of banks.
It added no asset sales were needed to preserve its credit rating of "A-".
(Additional reporting by Esha Dey in Bangalore; Editing by Sriraj Kalluvila and Greg Mahlich)
By Ludwig Burger