2018 may have been the worst year for the Dow Jones Industrial Average in a decade, but Merck managed to easily buck that trend.
Shares of the pharmaceutical giant are up more than 30 percent for the year, on pace for their biggest annual gain since 2006. Merck is also one of six Dow stocks to have posted a gain this quarter, rising more than 6 percent. Meanwhile, the Dow has fallen 6.7 percent in 2018 to mark its worst yearly performance since 2008.
A key driver for Merck's outperformance was the strong ramp-up in sales of Keytruda, a drug used to treat various forms of cancer. Keytruda sales surged 150 percent and 89 percent in the first and second quarter, respectively. Sales of the drug also climbed 80 percent during the third quarter on a year-over-year basis.
Vamil Divan, an analyst at Credit Suisse, said Merck and other pharmaceutical stocks also benefited from a "rotation" into defensive sectors like health care. "We expect some of that rotation to continue, but also see our companies needing to deliver innovation in order to overcome pricing pressures and drive further upside," Divan, who has Merck pegged as a top pick, wrote in a note to clients earlier this month.
Shares Pfizer, one of Merck's biggest competitors, were the second-best Dow performers this year with a gain of more than 18 percent, also benefiting from the rotation into more defensive names. Merck has a dividend yield of 2.9 percent, while Pfizer has a 3.3 percent payout.
Microsoft, Nike and Visa rounded out the Dow's top five stocks as they all jumped at least 14 percent.
These strong yearly performances were outweighed by steep losses in Goldman Sachs, IBM, DowDuPont, Caterpillar and 3M, however.
Goldman Sachs was the worst-performing Dow stock of 2018, dropping about 36 percent. The stock has been under pressure this year as a scandal related to the defunct Malayan investment fund 1MDB lingers. Bank of America Merrill Lynch downgraded Goldman back in November, noting uncertainty over the scandal could fester.
IBM, meanwhile, struggled this year as it continued its transition away from enterprise technology as its main source of revenue. Caterpillar and 3M were pressured by an ongoing trade war between China and the U.S. as a large portion of their profits comes from overseas.
—CNBC's Michael Bloom contributed to this report.