The S&P 500 Index (^GSPC -0.46%) surged late in the day Friday, helped along by mega-tech stocks Apple (AAPL 0.52%), Amazon (AMZN -1.65%), and Facebook (META -10.56%). The index ended the day up 0.77%. The rally comes despite slow progress by Congress in agreeing on another round of stimulus measures.

Apple, Amazon, and Facebook stocks all surged on Friday after the companies beat analyst expectations dramatically. Apple reported surprise iPhone growth, Amazon generated record profits, and Facebook battled through major headwinds to grow sales by a double-digit percentage.

Hand with hologram of globe.

Image source: Getty Images.

Apple gadgets in demand

Apple was one of the S&P 500's biggest gainers on Friday as investors snapped up shares following an earnings report that vastly exceeded expectations. While Apple was expecting conditions to worsen early in the pandemic, it saw better-than-expected demand in May and June.

iPhone sales were up slightly thanks to the launch of the inexpensive iPhone SE, and sales of Macs and iPads grew by double-digit percentages. Economic stimulus likely played a role in driving Apple's total revenue up 11% for the quarter. Direct payments to Americans landed in bank accounts during the quarter, and some people collecting unemployment benefits were making more money than when they were employed thanks to a supplemented benefit from the federal government.

Apple's sales could take a hit in the coming quarters if stimulus spending is dialed back, although the launch of 5G iPhones later this year may be enticing enough to get consumers to open their wallets. Apple stock gained 10.6% on Friday.

Amazon benefits from e-commerce shift

It's clear from Amazon's earnings report that the growth of e-commerce has accelerated. The company reported 40% revenue growth and record profits in the second quarter as many retail stores were either closed or operating under restrictions while stay-at-home orders were in effect. Notably, online grocery sales tripled year over year.

Amazon's cloud computing business didn't do quite as well; revenue was up just 29%. Amazon Web Services will be exposed to the impact of business failures and shrinking IT budgets as the pandemic ravages the U.S. economy.

Whether this shift to e-commerce persists after the pandemic has passed remains to be seen. For now, Amazon is well positioned to capture an increasing share of total retail spending. Amazon stock gained 3.7% on Friday.

Facebook grows despite headwinds

Facebook is facing a weak advertising-spending environment and boycotts from some of its large customers, but none of that was enough to derail its second-quarter results. Revenue was up 11% year over year, sluggish compared with recent quarters but far better than analysts were expecting.

A surge in active users helped the cause, with Facebook daily active users (DAUs) up 12% to 1.79 billion. DAUs for Facebook's family of apps jumped 15% to 2.47 billion. The company expects ad revenue growth to be similar in the third quarter compared with the second quarter, but things can change quickly with the pandemic nowhere near under control in the United States. Facebook stock gained about 8.2% on Friday.