(AP) -- Stocks racked up more gains Friday as Wall Street closed out its best month since November 2020, a welcome breather for investors after a punishing year for the market.
The S&P 500 index, a benchmark for many stock funds, rose 1.4% and finished 9.1% higher for July. A rebound in technology stocks, big retailers and other companies that rely on direct consumer spending helped power the index's broad gains this month. The index is still down 13.3% for the year.
The tech-heavy Nasdaq rose 1.9%, ending the month 12.4% higher, while the Dow Jones Industrial Average rose 1% and notched a 6.7% gain for the month.
The latest rally came as investors weighed a mix of company earnings reports and new data showing inflation jumped by the most in four decades last month.
Stock gains in recent weeks have been fueled by better-than-expected corporate earnings reports and falling bond yields, which have pulled back after soaring much of this year on expectations of higher interest rates.
"You've had 10-year Treasury yields come down precipitously," said Rob Haworth, senior investment strategist at U.S. Bank Wealth Management. "With inflation so hot, I think the expectation is the Fed stays on path, but it's damaging enough for the economy that they're going to have to pivot in 2023."
The S&P 500 rose 57.86 points to 4,130.29. The Dow gained 315.50 points to close at 32,845.13. The Nasdaq rose 228.09 points to 12,390.69.
Smaller company stocks also gained ground. The Russell 2000 rose 12.20 points, or 0.7%, to 1,885.23. It ended July with a 10.4% gain.
Weak economic data, including a report Thursday showing that the U.S. economy contracted last quarter and could be in a recession, have also spurred stocks higher by giving some investors confidence that the Federal Reserve will be able to dial back its aggressive pace of rate hikes sooner than expected.
The central bank raised its key short-term interest rate by 0.75 percentage points on Wednesday, lifting it to the highest level since 2018. The Fed is raising rates in a bid to slow the U.S. economy and quell inflation.
An inflation gauge that is closely tracked by the Federal Reserve jumped 6.8% in June from a year ago, the biggest increase in four decades, leaving Americans with no relief from surging prices. On a month-to-month basis, inflation accelerated to 1% in June from May's 0.6% monthly increase, the Commerce Department said Friday.
The figures underscored the persistence of the inflation that is eroding Americans' purchasing power, dimming their confidence in the economy and threatening Democrats in Congress in the run-up to the November midterm elections.
Some market watchers advised against placing too much emphasis on the June data, however.
"This inflation metric is for June and we know much has changed since then, especially gas prices, so investors should put this inflation report into historical context," said Jeffrey Roach, chief economist for LPL Financial. "Looking ahead, July inflation rates will ease a bit from the previous month as food and energy costs should wane in July."
Still, inflation hit one company in its earnings on Friday: consumer staples giant Proctor & Gamble. Shares in the maker of Tide laundry detergent fell 5.3% after the company said consumers were cutting back, but the company's recent price increases were keeping profits up.
Other company earnings reports were more encouraging.
Exxon and Chevron posted record quarterly profits last quarter amid high oil and gas prices. The two companies made $46 billion last quarter and roughly four times the amount of money they made in the same period a year earlier. Chevron shares jumped 8.9% to a six-week high, while Exxon rose 4.6%.
Amazon surged 10.4% for the biggest gain in the S&P 500 after the company posted a quarterly loss, but its revenue jumped sharply in the quarter.
Apple rose 3.3% after its quarterly earnings came in better than Wall Street expected. The iPhone maker saw its profit for the April-June period decline by 10% while revenue edged up 2% as it grappled with manufacturing headaches and inflation pressures.
It was a mixed day in the bond market. The two-year Treasury yield, which tends to move with expectations for the Fed, rose to 2.89% from 2.87% late Thursday. The 10-year yield, which influences mortgage rates, fell to 2.65% from 2.67%.