The Nasdaq Composite hit a record high on Tuesday as strong gains in Amazon and a rebound in Netflix shares led to a big comeback in tech stocks.

The tech-heavy Nasdaq rose 0.6 percent to 7,855.12, after falling as much as 0.7 percent, as Amazon reached an all-time high. Meanwhile, Netflix closed just 5.2 percent lower after falling as much as 14.1 percent earlier in the session.

Netflix initially plunged after reporting weaker-than-expected subscriber growth. The streaming giant said Monday afternoon that domestic subscribers grew by 670,000 in the previous quarter, while international additions rose by 4.5 million. Analysts polled by StreetAccount expected domestic gains of 1.23 million and 5.11 million new international subscribers.

Bank of America Merrill Lynch said the drop presented a "compelling" buying opportunity, noting the company "never misses twice" when it comes to subscriber growth. "Historically, following a net adds miss, Netflix tends to set guidance cautiously and deliver large beats in the following quarters,” analyst Nat Schindler said in a note to clients Monday.

Netflix's steep decline dragged down other major tech stocks. Google-parent Alphabet dropped as much as 1.2 percent, while Amazon and Facebook fell more than 1 percent earlier in the session. Alphabet and Facebook recovered to rise by 1.4 percent and 1.3 percent, respectively, and reach record highs.

Amazon rose 1.2 percent after data from Feedvisor showed strong sales growth for the first 12 hours of Prime Day compared to last year. Earlier, Amazon fell 1.4 percent amid glitches during the company's annual sales event.

"The bounce-back is definitely warranted," said Marc Chaikin, CEO of Chaikin Analytics. "The reason those stocks went down together is because of three letters: ETFs."

"There are so many ETFs dominated by these names," he said, noting the stocks were able to come back once the selling in those funds subsided.

Tech is the best-performing sector in the market this year, rising nearly 15 percent through Monday’s close. Also, just a handful of tech shares are responsible for more than 80 percent of the S&P 500's gains this year.

The Dow Jones Industrial Average and S&P 500 also got a boost from tech as well as strong earnings from Johnson & Johnson. The Dow rose 55.53 points to 25,119.89, with Johnson & Johnson outperforming. The S&P 500 gained 0.4 percent to close at 2,809.55, led by gains in tech and consumer staples. Both indexes fell as much as 74.75 points and 0.3 percent, respectively.

Johnson & Johnson rose 3.5 percent after reporting earnings and revenue that topped expectations. Goldman Sachs also posted better-than-expected earnings, but its stock fell 0.6 percent. The bank also announced that David Solomon will take over the CEO role from Lloyd Blankfein on Oct. 1.

Meanwhile, Charles Schwab jumped 3.6 percent on stronger-than-forecast results.

The earnings season “is off to a great start,” said Nick Raich, CEO of The Earnings Scout. “Up until now, more than 80 percent of the S&P 500 companies that have reported have beaten earnings estimates.”

“Most importantly, third-quarter estimates are only inching down thus far. That’s a good thing because they’re not falling off a cliff,” Raich said. “Up until this year, that was the trend every quarter for six or seven years.”

Federal Reserve Chairman Jerome Powell said in testimony to the Senate Committee on Banking, Housing and Urban Affairs that he supports more rate hike given the “considerably stronger” economic growth.