Nothing has been able to derail the monthly winning streak for mutual-fund investors.

But things came close in May.

Worries about inflation helped to cause volatility in stocks and other investments during May. In the end, however, stock funds—along with the overall stock market—once again came out on top. U.S.-stock funds tracked by Refinitiv Lipper (including mutual funds and exchange-traded funds) squeaked out an average return of 0.5% in May, to push their year-to-date gain to 14.2%.

It was the seventh straight monthly gain for U.S.-stock funds.

International-stock funds did even better in May, with a 3.2% gain, though their year-to-date gain of 10.2% still trails their U.S. counterparts.

“The market has been resilient in the face of accelerating inflation,” says Jay Hatfield, portfolio manager of an energy-focused exchange-traded fund, InfraCap MLP ETF (AMZA). It has helped that the Federal Reserve has indicated that It won’t taper, or slow the pace, of its bond-buying stimulus until there is full employment.

He says there are still sectors of the market that are undervalued and thrive in an inflationary environment, including energy, materials, financials and real-estate investment trusts. “As inflationary expectations rise, the market is rotating into these sectors and out of tech rather than declining on an absolute basis,” Mr. Hatfield says.

Lipper’s financial-services funds category rose 2.5% in May, to push the year-to-date gain to nearly 28%. Natural-resources funds were up 8.2% in May, to push the year-to-date gain to more than 36%.

Real-estate funds were up an average 0.8%, to make the year-to-date gain nearly 17%.

Bond funds also rose for the month. Funds tied to intermediate-maturity, investment-grade debt (the most common type of fixed-income fund) were up 0.4%, to trim their year-to-date decline to minus 1.8%.

Mr. Power is a Wall Street Journal news editor in South Brunswick, N.J. Email him at william.power@wsj.com.