By Anna Isaac and David Benoit

The Dow Jones Industrial Average eked out a fourth-straight gain Wednesday after the Federal Reserve signaled it was ready to keep interest rates near zero for three more years and unpin the economy even in the face of inflation.

Still, stocks lost some of their steam in the last hour of trading. The Dow finished up 36.78 points, or 0.1%, at 28032.38 after trading up more than 360 points following the central bank's announcement. The S&P 500 slipped into negative territory by the end of trading, closing down 0.5%, or 15.71 points, to 3385.49. That ended the S&P's three-session winning streak.

The Nasdaq Composite Index fell 1.25%, or 139.85 points, to 11050.47 as big tech stocks sold off. The indexes are all still down this month, with the Nasdaq now off more than 6% in September.

In its last meeting before the November election, the Fed left rates unchanged, as was widely expected, and said it now expects them to stay there through 2023. The committee's expectations for economic growth and unemployment in 2020 have grown sunnier since the last meeting. They now expect gross domestic product to fall 3.7% in 2020, compared with a 6.5% drop they forecast in June.

The meeting is the Fed's first since forging a new framework governing how to conduct policy over the long run. Investors have been eager for more guidance on how changes will work in practice, including from Chairman Jerome Powell's remarks. The Fed said it would keep inflation above 2% "for some time" to achieve its goals.

William O'Donnell, a U.S. rates strategist at Citigroup, said there were few surprises for the market but some clarity that the Fed will watch a variety of economic indicators to gauge whether policies are having the desired impact.

"We're now basically in a new Fed era of outcome-based guidance," he said. "It just leaves us with the conclusion that what the Fed did was up its commitment but did so with some flexibility."

For instance, he pointed to Mr. Powell's comments about watching unemployment levels, but also labor-force participation and wage data to get a broader picture of "full employment."

In bond markets, the yield on the benchmark 10-year U.S. Treasury turned higher after the Fed's announcement, closing at 0.686%, from 0.678% Tuesday.

Investors are also continuing to assess the prospects for additional government spending, with negotiations complicated by calculations surrounding the November elections. On Tuesday, House Speaker Nancy Pelosi said the chamber should remain in session until lawmakers can strike a bipartisan agreement on new coronavirus relief. White House adviser Jared Kushner said any deal could be a ways off.

Mr. Powell suggested more fiscal stimulus was needed, as the Fed stressed the coronavirus pandemic continued to dominate the economy.

Markets would likely cheer more government action, but have grown pessimistic on the odds.

JPMorgan strategists recently raised their S&P 500 target for this year to 3600, predicting another nearly 6% in gains. But that was based on stronger corporate earnings and economic data, as they have tempered their expectation for more stimulus.

"When I look at where the stimulus talks are, the odds of something getting done are very, very slim," Joyce Chang, the bank's head of research, said Wednesday. "Both sides are far apart."

The lack of stimulus has seeped into some data. Retail spending rose 0.6% in August for the fourth straight monthly increase, according to data from the Commerce Department, but at a slower pace than expected as some extra unemployment benefits ran out.

Broadly, energy stocks gained while big technology companies, which have helped fuel the market's recent gains, pulled back.

Brent crude rose 4.2%, or $1.69 a barrel, to $42.22, its best day since June, after data showing that U.S. crude inventories unexpectedly declined. Hurricane Sally, which slammed into Alabama as a Category 2 storm early Wednesday morning, has curtailed offshore oil production and is likely to further hit U.S. supply.

Chevron was the biggest gainer in the Dow, up 2.9%, or $2.21, to $78.56.

Shares of FedEx rose 5.8%, or $13.63, to $250.30 as one of the best performers in the S&P 500. The delivery company posted the highest quarterly revenue in its history as the pandemic spurred residential-shipment levels normally seen during the holiday season. It's now up 66% this year and powering the Dow Jones Transportation Average to the edge of new highs.

Tech stocks, already mired in a September cool-down from their big gains this year, fell again.

Facebook shares slipped 3.3%, or $8.90, to $263.52 after The Wall Street Journal reported that the Federal Trade Commission was gearing up to file a possible antitrust lawsuit against the company, in a case that would challenge the company's dominant position in social media. Other tech stocks slid, including Apple, down 3%, or $3.41, to $112.13.

Still, the IPO of Snowflake, a cloud-based data management provider, more than doubled, giving it a market valuation of about $70 billion. It closed at $253.93 on heavy volume.

Write to Anna Isaac at anna.isaac@wsj.com and David Benoit at david.benoit@wsj.com