In times of market turmoil, investors often embrace gold. And when that happens, gold-mining stocks tend to do even better.

This slideshow requires JavaScript.

♦♦♦ Stock Market News Today ♦♦♦

In times of market turmoil, investors often embrace gold. And when that happens, gold-mining stocks tend to do even better. That has certainly been the case so far this month. New York gold futures are up 2.7% so far in October versus a 3.6% decline for the S&P 500. Shares of many of the world’s biggest gold miners, meanwhile, have notched double-digit gains.

Companies like Toronto’s Barrick Gold Corp ABX +3.42% , South Africa’s AngloGold Ashanti AU +3.66% and Acacia Mining are all up around 15% to 18% after a bruising summer. The VanEck Vectors Gold Miners exchange-traded fund and the iShares MSCI Global Gold Miners fund—which track indexes of global gold-mining firms—are up around 8% to 9% this month.

Gold-miner stocks allow investors to double down on bets the gold price will rise. These companies have higher fixed-investment costs and can become much more profitable when gold prices climb. Many of these companies pay out hefty dividends, too.

This slideshow requires JavaScript.

Hopes for further consolidation are adding to the momentum after Barrick Gold in September agreed to buy Randgold Resources Ltd. for $6 billion. Gold miners’ rapid ascent during the selloff marks a turnaround from other recent episodes of market turbulence. While gold and related assets have historically been used as a safe place to invest during times of economic or political stress, they found few fans during a selloff at the start of the year or during the summer turmoil in emerging markets.

Because concerns at the time largely centered around the prospect of rising U.S. interest rates, investors sought shelter in the U.S. dollar instead, in turn making gold less attractive to overseas buyers. The ICE Dollar Index rose about 9% between February and the middle of August, while New York gold futures fell about 12% and the VanEck gold miner fund fell about 20%. Rising rates also make assets like gold less attractive, because they don’t offer a yield. And both gold and miners haven’t fared so well in recent years. From highs in 2011, prices of the metal and the VanEck ETF are down around 35% and 70%, respectively. Meanwhile, the iShares fund has also tumbled 70% since its inception in 2012.

This time is different. The ICE Dollar Index has barely budged during this month’s selloff, the Federal Reserve’s plans for interest rates are well telegraphed and investors have turned skeptical that the dollar has much further room to rise.

“Given the strength of the U.S. dollar we’ve seen and slight concern now about the fiscal position in the U.S. following stimulus measures and tax reform, there’s some concerns around the U.S. dollar as an ultimate safe haven,” said Roger Jones, head of equities at London & Capital.

The U.S. government ran its largest budget deficit in six years during the fiscal year that ended last month, totaling $779 billion.

Meanwhile, “this [selloff] is more about a growth scare than February-March, when it was more about a rate hike scare,” Mr. Jones said. “If there’s another slowdown in growth, goldmining stocks will be at the forefront of investors’ minds.”