Amazon.com Inc. shares climbed more than 10% in premarket trading on Friday, boosted by the tech giant’s second-quarter sales beat and robust third-quarter guidance.

Shares of Amazon.com Inc. AMZN, +11.31% rose 10.7% to $135.36 before market open.

After market close Thursday Amazon reported second-quarter sales of $121.2 billion, up from $113.08 billion in the year-ago quarter, and above Wall Street’s forecast of $119 billion.

Amazon reported a second-quarter loss of $2 billion, or 20 cents a share, after posting a profit of 76 cents a share in the same period last year. FactSet consensus was for earnings of 12 cents a share. However, the second-quarter results included a loss of $3.9 billion as a result of a valuation decline for an investment in Rivian Automotive Inc. RIVN, -1.02% Last year’s results were adjusted for Amazon’s 20-to-1 stock split.

Cloud growth helped fuel the company’s second-quarter sales. Amazon Web Services (AWS) revenue was $19.74 billion during the quarter, up from $14.8 billion in the same period last year.

See Now: Amazon stock jumps 14% as sales beat and AWS growth overcome a second straight quarterly loss

While the results marked the first time that Amazon has posted back-to-back quarterly losses since the since the second and third quarters of 2014, analysts were impressed with the company’s numbers.

Amazon is back on track with accelerating revenue, cost structure progress and “return to Middle Earth,” wrote J.P. Morgan analyst Doug Anmuth, in a note released on Friday.  “AMZN’s 2Q results came in just ahead of the high end of guidance on both revenue & operating income as the company executed well despite inflationary pressures,” he wrote.

Amazon improved its year-over-year cost pressures from $6 billion in the first quarter to $4 billion in the second quarter, with most of the improvement coming in productivity and staffing, according to Anmuth. The analyst also pointed to Amazon’s investments in AWS and Prime Video.

“Notably, Prime Video will launch The Lord of the Rings: The Rings of Power on September 2 & Thursday Night Football will start on September 15,” he wrote. “Suffice to say, Middle Earth, the NFL, and high profile talent do not come cheap, but we also can’t remember a more anticipated period of content for Prime Video, which should pay dividends in terms of Prime members & retail sales.”

J.P. Morgan raised its Amazon price target to $185 from $175. “We reiterate our overweight rating & AMZN remains our Top Pick,” wrote Anmuth.

For the third-quarter Amazon gave revenue guidance of $125 billion to $130 billion. Analysts tracked by FactSet were forecasting revenue of $126.49 billion. The third quarter will also include sales from Prime Day earlier this month, which Amazon said established record sales.

Amazon Prime Day in one chart: Americans stocked up on electronics, household essentials amid inflation

Amazon’s strong results and third-quarter guidance reflect the power of Prime, AWS and the company’s advertising business in an uncertain macro environment, according to Truist Securities analyst Youssef Squali.

“We’re incrementally positive on AMZN post its beat & raise out of 2Q earnings, which reflects the power of Prime, whose value in this challenging environment continues to rise with 1-2 day free delivery, wide selection, and low prices,” he wrote. “Prime plus sustained growth in AWS and in the ads biz have helped AMZN thrive in the face of a weakening macro, which is all the more impressive considering AMZN control ~41% U.S. [ecommerce] share (our estimate),” he wrote.

Truist reiterated its Amazon buy rating and raised its price target to $180 from $175.

D.A. Davidson also highlighted the impact of AWS on Amazon’s results. “We attribute its better-than-expected 2Q22 sales to its cloud computing and advertising efforts and its favorable revenue outlook for 3Q22 to those items and the benefit of having Prime Day in 3Q22 versus 2Q21,” wrote analyst Tom Forte.

Amazon’s advertising business recorded $8.76 billion in revenue in the second quarter, up from $7.45 billion in the same period last year.

See Now: Will Amazon and GrubHub take a bite out of Uber and DoorDash’s food-delivery dominance?

D.A. Davidson reiterated its Amazon buy rating but lowered its price target to $151.00 from $156.25. “Our new price target is based on our updated discounted cash flow model, including our long-term adj. EBITDA margin forecast of 22.0% (unchanged) versus 15.0% in 2021,” wrote Forte.

Wedbush pointed to the “resilient consumer demand” Amazon is enjoying, which offset macroeconomic pressures.

“Despite inflationary pressures, a tight labor environment, and suboptimal fixed cost leverage, Amazon delivered strong second-quarter results that benefited from elevated levels of consumer demand and better optimization of its fulfillment network,” wrote Wedbush analyst Michael Pachter. “Longer-term, Amazon should benefit from steady margin expansion driven by the rapid growth of its cloud and advertisement businesses.”

The broker maintained its outperform rating and $175 price target for Amazon.

Raymond James maintained its outperform rating for Amazon, as fulfillment improvements helped drive the company’s solid second-quarter results and outlook.

“2Q revenues were at the high end of guidance and Amazon noted it is not seeing any discounting pressures,” wrote Raymond James analyst Aaron Kessler. “Importantly, Amazon is gaining back fulfillment efficiencies as it right sizes its staffing (employee count down ~100K q/q) which drove improved operating margins for 2Q and Amazon expects continued improvements in fulfillment efficiencies and fixed cost leverage in 2H.”

See Now: U.S. stock futures boosted by jumps for Apple and Amazon after earnings

Raymond James lowered its Amazon price target to $165 from $164.

Amazon shares have fallen 26.7% year-to-date, compared with the S&P 500 index’s SPX, +0.79% decline of 14.6% and the Dow Jones Industrial Average’s DJIA, +0.29% fall of 10.5%.

Of 52 analysts surveyed by FactSet, 49 have overweight or buy ratings for Amazon, two have hold ratings and one has a sell rating.