By Caitlin Ostroff and Gunjan Banerji

The S&P 500 edged higher in the final trading day of the week, notching a fourth consecutive month of gains.

The broad stock-market gauge added 3.23 points, or 0.1%, to 4204.11. The tech-heavy Nasdaq Composite gained 12.46 points, or 0.1%, to 13748.74. The Dow Jones Industrial Average gained 64.81 points, or 0.2%, to 34529.45.

The S&P 500 and Dow clinched gains for the month of May, while the Nasdaq logged a decline, snapping a six-month streak of wins.

The month has been marked by big swings in everything from stocks to bitcoin. Worries about inflation injected a jolt of volatility to markets earlier in May, though major U.S. indexes have regained their footing since as investors rapidly stepped back into markets.

The Federal Reserve's preferred measure of inflation -- the price index for personal-consumption expenditure, excluding food and energy -- rose 3.1% from a year earlier. A surge in demand after Covid-19 restrictions were lifted, coupled with supply chain strains, likely led to a rise in prices last month.

Investors and central bankers have closely monitored inflation data to see if these pressures are likely to be temporary or long-lasting. Such data will guide whether policy makers relax measures that have helped markets recover from pandemic lows.

"We don't think the Fed's going to raise rates aggressively. We think they'll remain behind the curve because they want to help the economy recover," said Paul Flood, investment manager at Newton Investment Management. "Everybody is expecting inflation in the short term."

Fresh data also showed that Americans extended a spending binge in April, as they continued catching up on activities they held off on during the pandemic, propelling the economy. Consumer spending rose 0.5% from March.

An increase in spending and a surge in the number of Americans that have been vaccinated have added to optimism about an economic recovery from the pandemic-induced recession.

That led many investors to increase bets in recent months on cyclical corners of the market like smaller companies and the financials and energy groups. The Russell 2000 index of small companies, for example, has risen for eight consecutive months, its longest winning streak since 1995.

A dizzying run for meme stocks continued this week. AMC Entertainment slipped Friday after closing at the highest level in four years the prior session. The shares have more than doubled this week, closing at $26.12 Friday.

Ulta Beauty shares rose $17.00, or 5.2%, to $345.36 after the beauty retailer swung to a profit during its latest quarter, as sales picked up with the economy rebounding.

Salesforce.com shares jumped $12.27, or 5.4%, to $238.10 after the cloud-software company reported first-quarter results and a second-quarter outlook that beat analysts' forecasts.

In bond markets, the yield on the 10-year Treasury note ticked down to 1.592% from 1.609% Thursday. Yields and prices move inversely.

Overseas, the pan-continental Stoxx Europe 600 stock index, which contains a swath of companies that benefit from global economic growth, rose 0.6% to a record.

In Asia, major benchmarks largely closed higher. Japan's Nikkei 225 advanced 2.1%, led by industrial companies.

China's Shanghai Composite Index declined 0.2%. South Korea's Kospi added 0.7%.

Write to Caitlin Ostroff at caitlin.ostroff@wsj.com and Gunjan Banerji at Gunjan.Banerji@wsj.com

(END) Dow Jones Newswires

05-28-21 1702ET