Stocks notched solid gains in the second quarter thanks to a perceived shift in the Federal Reserve’s appetite for interest-rate cuts, extending a rally that propelled the S&P 500 to record highs.
The benchmark overcame an escalation in the U.S.-China trade fight to close Friday up 17% so far this year, its best first-half performance since 1997. That prolonged the more than a decadelong bull market for stocks and erased steep losses that jarred investors at the end of last year.
Stocks also rose despite mounting fears of an economic slowdown that have pushed bond yields down globally. The yield on the 10-year U.S. Treasury closed the quarter at 2%, nearly a half-percentage-point drop from the end of March, a downward lurch that took many investors by surprise.
President Trump walks past G-20 member flags on Friday. Investors will be watching for signs that trade tensions between the U.S. and China are easing. Photo: ludovic marin/Agence France-Presse/Getty Images
“The second quarter is a fabulous example of the volatility that is wrought by headlines and emotions,” said Michael Farr, president of wealth-management firm Farr, Miller & Washington.
The S&P closed Friday at 2941.76, up 16.84 points, or 0.6% on the day and 3.8% for the second quarter. The Dow Jones Industrial Average rose 73.38 points, or 0.3%, to 26599.96 and is now up 14% in 2019.
Whether the market run continues may depend on events this weekend, which could mark a pivotal turning point, some analysts and investors said. All eyes are on President Trump and China’s President Xi Jinping as they meet in Japan for a Saturday lunch on the sidelines of the Group of 20 summit.
If the two sides come to an agreement on trade, it could ease fears of a tariff-caused slowdown. Such an agreement would relieve pressure from companies that do business or buy supplies from China—such as semiconductor companies and certain retailers. However, an agreement also could lower the chances of the Fed cutting rates in the near future, the anticipation of which has buoyed stocks for the past month.
“The G-20 is just one on the list in order to understand how much uncertainty might continue to stay on trade and eventually on growth,” said Monica Defend, head of strategy and deputy head of group research and macro strategy at Amundi, pointing to the recent drop in bond yields, which signals gloomy expectations for global output.
During the second quarter, more than 60% of the companies in the Dow industrials and the S&P 500 rose, with technology firms notching some of the biggest gains. Tech stocks were on a roller-coaster ride during the period as their profits tend to rely heavily on demand from China for their goods.
Materials stocks also swung wildly, hit by sliding prices of commodities like oil and copper. Those tend to lose ground when investors are worried about the prospects for global growth.
Shares of smaller companies, which are typically touted as havens when turmoil swirls overseas, lagged behind broader indexes, a move some analysts blamed on fears that the U.S. economy’s growth is cooling. The benchmark small-capitalization index Russell 2000 rose 1.7% in the second quarter.
Companies that are more insulated from global growth fears, including tech stalwart Microsoft Corp. and Walt Disney Co. were among the biggest gainers in the Dow. Microsoft is the best performer in the Dow in 2019, up 32%.
The second quarter saw an extension of the volatility that has plagued the stock market since October. In the final three months of the year, stocks lurched lower, spooked by rising interest rates, trade tensions and signs that China’s economy may be slowing. The S&P 500 ended the fourth quarter down 14%. The following three months, stocks clawed back much of those losses, rising 13% as the Fed began to back off its plans for future rate increases and trade tensions appeared to be easing.
It wasn’t until April that the S&P 500 climbed back to its October 2018 highs. The Dow industrials remain 0.9% below their record, also set in October.
The bulk of the market’s second-quarter gains occurred during April. First-quarter earnings topped beaten-down expectations and investors embraced the belief that the U.S. and China were close to reaching a detente in trade negotiations.
But that optimism vanished in May after President Trump said he would drastically ramp up U.S. tariffs on Chinese imports as talks fell apart. China and the U.S. took turns ratcheting up their rhetoric and threatening higher tariffs. Stocks and investor confidence tumbled in response.
In early June, Federal Reserve Chairman Jerome Powell addressed the fears of how the continuing trade spat could hurt the economy, saying the central bank was closely monitoring the escalation in tensions and indicating it could respond by cutting rates if the economic outlook deteriorated. Investors cheered the news, setting the stock market up for its monthlong climb back toward records.
—Avantika Chilkoti contributed to this article.
Write to Corrie Driebusch at corrie.driebusch@wsj.com