By Peter Loftus And Dana Cimilluca 

Merck & Co. agreed to buy Cubist Pharmaceuticals Inc. for $8.4 billion as the drug giant pushes deeper into antibiotics, an area seeing renewed interest because of the rise of dangerous new infections.

The deal, which also includes the assumption of $1.1 billion in debt, is worth $102 a share, a 37% premium to Friday's close. The Wall Street Journal and other media had reported on Friday that Merck was nearing a deal for Cubist worth about $100 a share.

The proliferation of so-called "superbugs" that are resistant to treatment with older antibiotics is a growing health threat. At least two million people in the U.S. become infected with drug-resistant strains of bacteria each year, and at least 23,000 people die as a result, according to the Centers for Disease Control and Prevention.

Merck Chief Executive Kenneth C. Frazier said in an interview that he has had discussions with doctors who have expressed alarm that drug makers aren't as focused on antibiotics research as they should be. "Many pharmaceutical companies are not focused on this field, although there's a huge societal imperative," he said.

Cubist shares jumped 35% Monday to $100.60, while Merck added 39 cents to $61.88.

Lexington, Mass.-based Cubist is one of few companies that specializes in drugs to treat infectious diseases and other conditions, primarily in a hospital setting. Its flagship drug Cubicin, an intravenous antibiotic used to treat serious infections--including those caused by bacteria resistant to older antibiotics--had $967 million in sales in 2013. The drug currently accounts for more than 80% of Cubist's sales.

Antibiotics traditionally hasn't been considered one of the drug industry's most lucrative areas, but some analysts believe new versions could garner higher prices as it becomes more important for hospitals to reduce infections and as resistance to traditional antibiotics grows.

Mr. Frazier said the deal arose from his conversations with Cubist CEO Michael W. Bonney about antibiotics research. The deal will help Merck beef up its lineup of products used in acute hospital care--one of four product areas that Merck identified as a priority in a 2013 strategy to narrow its focus. The other key areas are diabetes, vaccines and oncology.

Merck's interest in Cubist appears to stem from a strategy announced in 2013 to narrow its focus to areas including diabetes, acute hospital care, vaccines and oncology.

Key products in Merck's hospital-acute-care portfolio include several antibiotics and antifungals. One of its experimental drugs, relebactam, was fast-tracked by the U.S. Food and Drug Administration in September. Relebactam fights beta-lactamase, an enzyme that can cause resistance to antibiotics like penicillin.

Merck expects the deal to add more than $1 billion to its revenue next year and begin adding to earnings the following year.

Merck is counting not only on near-term sales from Cubist but also on future sales from newer products. Cubist has applied for U.S. and European regulatory approval of Zerbaxa, a proposed treatment for certain complicated infections. RBC Capital Markets estimates Zerbaxa could eventually generate more than $1.5 billion in annual sales if it is approved for sale.

Still, the deal has some risks, especially in light of the $8.4 billion price tag. Cubicin faces the threat of generic competition in coming years, the timing of which will depend upon the resolution of patent litigation with Hospira Inc., which has challenged the validity of a U.S. patent for the drug. Also, Zerbaxa could face competition from a new antibiotic co-developed by Actavis PLC and AstraZeneca PLC.

A federal judge in Delaware issued an order Monday afternoon--several hours after the Merck-Cubist deal was announced--concluding that certain claims in Cubist patents covering Cubicin were invalid because the claimed inventions would have been obvious to people skilled in drug development. The patents are due to expire in 2019 and 2020. Evercore ISI analyst Mark Schoenebaum said it appeared the ruling could allow Hospira to launch a generic version of Cubicin in 2016.

Spokesmen for Cubist, Hospira and Merck couldn't be reached to comment on the patent ruling. Earlier Monday, Merck executives said they had considered a range of possible outcomes of the ongoing patent litigation surrounding Cubicin, and said the Cubist deal looked good under all scenarios.

Shares of Hospira rose more than 2% in after-hours trading, while the stocks of both Merck and Cubist slid more than 1%.

The transaction has been unanimously approved by the boards of both companies and is expected to close in the first quarter of next year. Merck plans to initiate a tender offer for Cubist's shares and will acquire the remaining stock through a second-step merger that won't require a shareholder vote.

Merck's leaders have made clear they aren't interested in pursuing large-scale acquisitions, but rather more modest-size, "bolt-on" deals that bolster the company's research-and-development pipeline and its product lineup.

Merck has an aging drug portfolio and its top selling product, diabetes treatment Januvia, isn't growing like it once did. The company recently got a cancer immunotherapy called Keytruda approved. In August, Merck acquired Idenix Pharmaceuticals Inc., a developer of hepatitis C drugs, for about $3.9 billion.

Merck's war chest for such deals has grown partly by the company's slimming down in other areas. The company sold its consumer-healthcare division to Bayer AG for $14.2 billion in October, and the company has unloaded other products in smaller deals.

Merck also reduced costs by laying off thousands of employees and closing offices.

Angela Chen contributed to this article.

Write to Peter Loftus at peter.loftus@wsj.com and Dana Cimilluca at dana.cimilluca@wsj.com

Access Investor Kit for Cubist Pharmaceuticals, Inc.

Visit http://www.companyspotlight.com/partner?cp_code=P479&isin=US2296781071

Access Investor Kit for Hospira, Inc.

Visit http://www.companyspotlight.com/partner?cp_code=P479&isin=US4410601003

Subscribe to WSJ: http://online.wsj.com?mod=djnwires