You might have missed it, but Amazon (AMZN 0.58%) stock quietly gained 81% in 2023.

While the market's attention was focused on Nvidia and other AI stocks amid the fanfare over ChatGPT and other generative AI applications, Amazon had one of its best years on record. The tech giant added roughly $700 billion in market value and bounced back from the 2022 bear market that saw its stock price get sliced in half.

Let's look at the major factors that sent Amazon stock higher last year before discussing the company's prospects in 2024.

An Amazon fulfillment worker

Image source: Amazon.

Tech stocks boomed

First, it's important to note that Amazon's gains didn't happen in a vacuum. Tech stocks soared last year, propelled by bargain prices at the beginning of the year and anticipation for a new AI revolution led by generative AI technology.

The Nasdaq Composite finished the year up 43% and the Nasdaq 100 jumped 54% higher. The following chart shows the performance of the "Magnificent Seven," or the seven most valuable tech stocks on the market.

NVDA Chart

NVDA data by YCharts

Remarkably, even though Amazon stock nearly doubled last year. that was only enough to put it right in the middle of the "Magnificent Seven" last year. Thanks to the rebound from the 2022 crash and the fervor over generative AI, nearly every major tech stock soared last year.

Profitability surged

Strategically, Amazon's biggest move in 2023 was taking a hatchet to its cost structure as CEO Andy Jassy sharpened the company's focus on profitability like never before. The company laid off around 27,000 corporate employees, its biggest layoff ever, and it cut experimental businesses such as its Scout home delivery robot and its Amazon Care healthcare service. The company even closed several of its cashierless Amazon Go stores, tamping down expectations for its once-promising "Just Walk Out" technology.

As a result of those moves and the continued growth of high-margin businesses like its third-party marketplace, advertising, and the Amazon Web Services cloud infrastructure business, the company saw its operating margin soar in 2023. It also benefited from growing into the fulfillment capacity it built during the pandemic.

For example, operating income in the third quarter soared from $2.5 billion in the previous year to $11.2 billion, as each of Amazon's three business segments all posted significant improvements. For the first three quarters of 2023, operating income reached $23.7 billion, compared with $11.2 billion in 2022.

Jassy seems poised to continue driving Amazon's profit higher as he makes more moves to leverage the company's earlier investments, including adding advertisements to Prime Video.

What to expect from Amazon in 2024

Because Amazon's profits surged in 2023, its valuation hasn't expanded as you might expect.

Amazon is still pricey, according to conventional metrics, trading at a price-to-earnings ratio of 75. However, that valuation seems justified, considering the company still seems to have to lot of room to expand its margins, especially as its revenue gradually shifts to its higher-margin businesses.

Artificial intelligence (AI) remains another opportunity for Amazon. The company launched its Bedrock AI hosting service for foundational models last year, and it's also forged a partnership with Anthropic AI. Amazon invested up to $4 billion in the maker of the AI chatbot Claude, a competitor to ChatGPT.

Amazon doesn't need to have a breakthrough in AI for the stock to move higher, but it would certainly help. Even without it, the company has enough competitive advantages based on its e-commerce business and AWS that it can keep growing without leading in AI.

The stock is unlikely to repeat its 81% jump in 2024, but more gains could be in store for Amazon as the company looks set to drive its margins even higher. Considering Amazon's wide economic moat, the company still has plenty of room to drive profits higher, and its stock price along with it.