Stocks and bonds posted strong gains in the second quarter of 2024, largely driven by enthusiasm for artificial intelligence (A.I.) and its expanding role across global markets. However, experts warn that the concentration of equities tied to A.I. could expose investors to heightened risks should the technology’s growth expectations falter.

In the United States, domestic stock funds delivered an average return of 14.8 percent for the quarter ending June 30, marking the best three-month performance since the rebound following the 2020 pandemic-induced market downturn. Over the past year, these funds appreciated by 23.2 percent, buoyed significantly by investor interest in A.I.-related companies.

The rally has evolved in phases, initially led by major technology firms including Alphabet, Amazon, Apple, Meta, Microsoft, Nvidia, and Tesla, collectively dubbed the “Magnificent Seven.” As enthusiasm broadened, attention shifted to semiconductor manufacturers, essential to A.I. hardware, and extended to sectors supplying the infrastructure needed to power A.I. data centers, such as machinery and power-generation companies like Caterpillar, as well as energy firms including Exxon Mobil.

Despite the wide influence of A.I., the impact is not uniformly positive. Some software companies, including Oracle and Salesforce, have faced declines amid concerns that A.I. applications may erode their traditional revenue streams. Meanwhile, Microsoft — both a developer of A.I. software and operator of data centers — has experienced mixed effects.

Internationally, stock funds recorded a 12.8 percent gain for the quarter and an even higher 26.8 percent return over the past year, outpacing many domestic funds. This strength is similarly linked to A.I., underscored by top holdings in global funds that include major semiconductor and technology firms such as Taiwan Semiconductor Manufacturing, Samsung Electronics, SK Hynix, ASML, and Tencent. Emerging market funds also saw notable gains, with a 22.4 percent quarterly return and a 45.9 percent return over 12 months.

Research from FTSE Russell highlights that since April, over half of the FTSE All-World Index’s returns have been attributable to A.I.-related stocks, rising to 75 percent when including the broader technology sector. The interconnectedness of global markets, influenced by geopolitical tensions—such as the recent conflicts involving the United States, Israel, and Iran—and the dominance of the A.I. trade, has increased market correlations worldwide.

Bond funds experienced more modest returns consistent with their generally lower risk profile. Taxable domestic bond funds gained 1.8 percent in the quarter and 5.1 percent annually, while municipal bond funds rose 2.4 percent and 6.7 percent, respectively. These returns came amid a backdrop of moderate interest rate increases and persistent inflation pressures.

Mixed-asset funds, including target-date retirement portfolios, posted solid performance. For example, target-date 2035 funds returned 9.4 percent for the quarter and 16.5 percent over the last 12 months, reflecting a higher stock allocation, while retirement income funds with more bond exposure achieved 5.1 percent quarterly and 10 percent yearly gains.

Despite the robust market performance, analysts caution that valuations remain elevated and that the concentration in A.I.-related stocks may heighten vulnerability to a downturn. Some strategists, including those at Bank of America, forecast a potential 4 percent decline in the S&P 500 for the remainder of the year, citing valuation concerns and ongoing geopolitical risks.

While A.I.-driven growth has powered impressive returns, the prevailing view among financial professionals emphasizes diversification to mitigate risk. Investors are encouraged to balance exposure across geographic regions and asset classes, maintaining liquidity and fixed-income holdings to navigate potential volatility.

In sum, artificial intelligence continues to be a central force shaping global financial markets. However, the sustainability of these gains depends on whether the technology’s rapid advancement meets escalating market expectations amid a complex landscape of economic and geopolitical challenges.