Big Tech continues to steamroll through the pandemic, and strong gains for some of the market’s most influential companies on Friday helped Wall Street close out its fourth straight winning month.

The S&P 500 rose 24.90 points, or 0.8%, to 3,271.12 following blowout profit reports from Apple and several other tech titans. The gains didn’t come easily, though, and the stock market flipped up and down through the day amid worries about the economy and whether Congress can find agreement on more aid for it.

The Dow Jones Industrial Average was down as many as 300 points before finishing the day up 114.67, or 0.4%, at 26,428.32. The Nasdaq composite jumped 157.64, or 1.5%, to 10,745.27 on the strength for tech stocks, which also accelerated in the last hour of trading.

Despite the gains, caution was clearly present across markets as the coronavirus pandemic continues to cloud the economy’s prospects. The 10-year Treasury yield touched its lowest level since it dropped to a record low in March. Gold also continued its record-setting run as investors searched for safety, while the majority of stocks in the S&P 500 sank.

Among the laggards were companies that most need the economy to get back to “normal” and the pandemic to subside, including many in the travel industry.

Expedia Group slumped 4.6% after it reported weaker results for the latest quarter than Wall Street expected. The company’s CEO, Peter Kern, called it “likely the worst quarter the travel industry has seen in modern history.”

Energy companies were also weak as the pandemic sucked away demand for oil. Chevron dropped 2.7% after it reported a worse loss for its latest quarter than Wall Street expected.

The economy cratered to its worst quarterly performance on record during the spring, and worries are high that continuing waves of coronavirus infections may halt what had been a budding recovery. An extra $600 in weekly unemployment benefits from the U.S. government is expiring with July’s end, and Congress continues to argue about how to provide more support for the economy.

Whether Washington can agree on more aid for out-of-work Americans — and quickly — is the biggest risk for the market in the near term, said Yung-Yu Ma, chief investment strategist at BMO Wealth Management.

“If it doesn’t happen in short order, there’s going to be a lot of disappointment and unease,” he said. “I think lawmakers are perhaps underestimating how quickly things could spiral downward without an extension in place. It would take only a few weeks before millions of people are cash strapped.”

The S&P 500 made its final leg back into positive territory for the day as top Democrats announced a meeting with White House representatives for Saturday morning to continue talks.

Also helping to prop up the S&P 500 was the power of big tech-oriented stocks. Amazon, Apple and Facebook each reported stronger profit for the latest quarter than Wall Street expected late Thursday, and each rose at least 3.7% in their first trading following the reports. They’re three of the biggest companies in the world, making up nearly 13% of the S&P 500 themselves, so their movements hold great sway over indexes.

Apple was particularly influential, rocketing up 10.5% following what Wedbush analyst Daniel Ives called a “Picasso-like performance” for its latest quarter.

Google’s parent company, another behemoth in the market, also reported stronger profit than analysts had forecast, but its stock stumbled.

Not only are Big Tech companies growing faster than the rest of the market, some investors have even begun seeing them as safer bets than other stocks because the pandemic is pushing more people online and directly into their wheelhouses. It’s a far cry from 20 years ago when tech stocks were seen as the riskiest investments.

The strength for tech is one of the reasons the S&P 500 rose 5.5% in July, its best month since April. Continued, massive amounts of aid from the Federal Reserve has been another linchpin. The index has climbed back within 3.4% of its record set in February after earlier being down nearly 34%.

The gains came even though companies have broadly been reporting sharp declines in their profits, as investors hope that a vaccine can be developed in the next year to corral the pandemic and get the economy closer to normal.

“The market knows earnings are going to be terrible now, with a few select exceptions, for the majority of companies,” Ma said. “What’s really holding up the equity markets is this idea that ‘Yes, it’s a terrible situation now, but the outlook for 2021 and beyond is markedly better.’”

Other markets have not shown as much exuberance, though. The yield on the 10-year Treasury ticked down to 0.53% from 0.54% late Thursday. It touched its lowest level since March 9, the day it dropped to its record intraday low just below 0.34%. The yield tends to move with investors’ expectations for the economy and inflation.

Gold for delivery in December, the most actively traded contract, rose $19.10 to settle at $1,985.91 per ounce after earlier climbing as high as $2,005.40.

Benchmark U.S. crude oil rose 35 cents to settle at $40.27 a barrel Friday. Brent crude rose 37 cents to $43.31 a barrel.

European and Asian markets closed broadly lower.