(AP) -- Stocks shook off another bout of volatile trading and finished solidly higher Friday, led by gains in technology and health care companies. Despite the rally, the S&P 500 still posted its fourth straight weekly loss, extending Wall Street's September swoon.
The S&P 500 rose 1.6% after flip-flopping between small gains and losses a few times in the early going. Stocks have been erratic this month, with indexes setting new highs to start the month and then falling sharply as investors worried that values for some of technology giants had risen too high.
The benchmark index ended the week with a 0.6% loss for its first four-week losing streak in more than a year. The index is now down 5.8% for September, following five straight months of gains.
The S&P 500 came within striking distance of a 10% drop from its all-time high earlier this week, what Wall Street calls a correction. Friday's gains reflect, in part, traders taking advantage of the selling to snap up stocks at lower prices, said David Lyon, global investment specialist at J.P. Morgan Private Bank.
"You're getting a market that got close to a 10% correction, so you're starting to see buyers step in to buy the dip," Lyon said.
Fund managers also tend to make moves toward the end of a quarter to bolster their portfolios, another reason for the end-of-the-week buying spree, he said.
The S&P 500 rose 51.87 points to 3,298.46. The Dow Jones Industrial Average gained 358.52 points, or 1.3%, to 27,173.96. The Nasdaq composite climbed 241.30 points, or 2.3%, to 10,913.56.
Smaller stocks also notched gains. The Russell 2000 index of small-cap stocks picked up 23.09 points, or 1.6%, to 1,474.91.
Stocks have struggled this month amid a long list of concerns. Chief among them is that stocks may have gotten too expensive following their record-breaking run through the summer, after storming 60% higher. Critics say Big Tech stocks in particular rose too high, even after accounting for their tremendous growth even as the coronavirus weakened the economy.
"This week, and the month of September, is really what we're calling the give-back month," Lyon said. "(Stock) valuations got expensive and this is a natural settling of the market, kind of giving back some of those advance returns that were probably ahead of themselves."
Big Tech stocks recovered from an early slide. Apple gained 3.8%, Microsoft rose 2.3% and Google's parent company added 1.1%.
Traders also bid up shares in cruise lines. Norwegian Cruise Line notched the biggest gain in the S&P 500, vaulting 13.7%. Carnival jumped 9.7% and Royal Caribbean Group climbed 7.7%.
Recently, investors' frustration has also grown with the inability of Congress to deliver more aid to the economy after weekly unemployment benefits and other stimulus expired.
Democrats in the House of Representatives are paring back their proposal for stimulus in hopes of jumpstarting talks with the White House, but investors are skeptical something can happen soon. Deep partisan divisions have kept Congress from acting, and tensions are on the rise due to the sudden vacancy on the Supreme Court following the death of Justice Ruth Bader Ginsburg.
President Donald Trump has also declined to guarantee a peaceful transfer of power if he loses the upcoming election, though other Republicans have pushed back on that idea.
"This stimulus deal needs to go through," Stephen Innes of AxiCorp said in a commentary. "With the risks building up everywhere you look, it doesn't seem to be a great time to be trying to pick the bottom of equity markets, but a stimulus relief bill will go a long way to nudging the market along."
Yet another report on Friday suggested that the economy's recovery is slowing without the support from Capitol Hill. Growth for U.S. orders of machinery and other long-lasting goods was just 0.4% last month, down from 11.7% in July. The figure on durable goods was much weaker than economists had forecast, though several said they saw a mixed picture underneath the headline numbers.
Among other concerns for markets are rising tensions between the United States and China and the possibility that investors' expectations for a COVID-19 vaccine arriving early next year may prove to be too optimistic.
On top of all the market's concerns are the pandemic and worries that worsening trends could lead to more profit-choking restrictions on businesses. Novavax surged 10.9% after it said it began a late stage trial of its potential COVID-19 vaccine in the United Kingdom.
Investors pulled $22.8 billion out of stock funds in the week ending Sept. 23, the largest outflow since March, according to a BofA Global Research report.
Wall Street's rally started in late March after the Federal Reserve and Congress pledged massive amounts of support for the economy. Budding economic improvements later in the spring helped accelerate the gains as widespread shutdown orders lifted.
The Fed has pledged to continue to hold short-term rates at nearly zero for years, but its chair Jerome Powell said repeatedly in testimony on Capitol Hill this week that the recovery will likely need more help from Congress as well.
In Europe, stocks closed mostly lower. Germany's DAX lost 1.1%, and France's CAC 40 fell 0.7%. The FTSE 100 in London rose 0.3%.
In Asia, Japan's Nikkei 225 rose 0.5% and South Korea's Kospi added 0.3%. Hong Kong's Hang Seng fell 0.3%, and stocks in Shanghai slipped 0.1%.
The yield on the 10-year Treasury held steady at 0.66%.