A few better-than-expected earnings reports helped lift stocks out of their recent funk Thursday, spurring a broad-based rally. The Dow Jones Industrial Average (^DJI -1.63%) and the S&P 500 (^GSPC -1.54%) didn't gain enough to completely reverse yesterday's losses, but they moved back into positive territory for the year.

Today's stock market

Index Percentage Change Point Change
Dow 1.63% 401.13
S&P 500 1.86% 49.47

Data source: Yahoo! Finance.

The battered technology sector rebounded today. The Technology Select Sector SPDR ETF (XLK -2.18%) rose 3.4% and the Communication Services Select SPDR ETF (XLC -1.49%) moved up 3.3% in advance of some big earnings reports from Amazon, Alphabet, and Intel

Helping stocks make a comeback were Tesla (TSLA -0.05%) and Microsoft (MSFT -1.32%), both of which surprised investors with very strong earnings reports.

Rising graph and pile of coins.

Image source: Getty Images.

Tesla surprises with a profitable quarter

Tesla dealt a blow to its skeptics by announcing that it turned a profit in the third quarter, giving the stock a 9.1% boost today. Revenue grew 129% to $6.82 billion, well above the $6.3 billion observers were expecting. The company achieved GAAP net income of $312 million and whopping non-GAAP earnings per share of $2.90. The average estimate on Wall Street was for a loss and even the most optimistic analyst predicted EPS of $0.88.

Tesla delivered 56,065 Model 3s to customers in Q3 on an average weekly production rate of 4,300 units, compared with 18,449 deliveries the previous quarter. According to the company, the Model 3 was the best-selling car in the U.S. by revenue and the fifth-best by units in Q3. Deliveries of Model S and Model X grew 24% sequentially to 27,710. Tesla generated $881 million in free cash flow in the quarter.

Making a huge difference to the bottom line was the fact that gross margin on the Model 3 improved far beyond expectations to over 20%. Model 3 gross margin was "slightly positive" in Q2 and Tesla had said to expect it to be about 15% in Q3. Labor hours per vehicle declined more than 30% as production stabilized, and higher volumes meant that fixed costs were spread out over more units.

Tesla reiterated guidance that it will be profitable again in Q4, and said that cash levels will remain flat even after repaying $230 million of convertible notes next quarter.

Cloud business propels Microsoft

Shares of Microsoft soared 5.8% after the company reported fiscal first-quarter results that beat expectations by a wide margin on the strength of its Azure cloud business. Revenue grew 18.5% to $29.1 billion and earnings per share jumped 36% to $1.14. Wall Street was expecting the company to earn $0.96 per share on revenue of $27.7 billion.

All three of the Microsoft's operating units posted double-digit revenue gains, led by Intelligent Cloud, which had a 24% increase to $8.6 billion, driven by 76% growth in revenue from its cloud infrastructure platform, Azure. More Personal Computing had revenue growth of 15% to $10.7 billion, thanks in part to a 44% increase in gaming revenue. Revenue from Productivity and Business Processes grew 19% to $9.8 billion on the strength of Office 365 commercial revenue growth of 36% and an increase of 33% from LinkedIn. Operating income as a percentage of revenue improved by 2.8 percentage points. 

Microsoft's cloud strategy is clearly working well, with the company able to integrate its enterprise software products and servers with its hybrid cloud offerings. The results were about as good as investors could hope for, and gave a much-needed boost to the technology sector today.