An investment in tech giants Amazon (AMZN -1.27%) and Alphabet (GOOG 0.89%) (GOOGL 0.97%) is appealing given their leadership positions in the massive markets of e-commerce and digital advertising, respectively.

In addition, both are applying the power of artificial intelligence (AI) across many areas of their businesses, boosting efficiency in their operations and improving products for customers. For instance, AI assists Alphabet's YouTube in processing the more than 500 hours of videos it receives every minute.

Ideally, you can invest in both companies. But if you could choose only one, which would it be? Here's an assessment of each to help you decide.

Reasons to buy Amazon shares

One reason to invest in Amazon is its dominance of the e-commerce industry. The company retains a gargantuan 38% share of the market. The next closest competitor, Walmart, holds a 6% share.

The company's third-quarter earnings report reflected its e-commerce strength. Online sales grew to $57.3 billion from $53.5 billion in the prior year. Amazon's cadre of Q3 businesses selling on its site added another $34.3 billion in Q3 sales, a 20% year-over-year jump.

But e-commerce isn't the only revenue contributor. The company's Amazon Web Services (AWS) platform, the leading cloud computing solution in the world, chipped in Q3 sales of $23.1 billion, a 12% year-over-year increase. Amazon also possesses an advertising business, which contributed another $12.1 billion in Q3 revenue, up from $9.5 billion in 2022.

Growth in these divisions helped bring Amazon's total Q3 revenue to $143.1 billion, a 13% year-over-year increase. Contributing to Amazon's success is its application of AI across many parts of its business.

AI is used in digital assistant Alexa and to provide consumers with product recommendations. AI manages a legion of robots working in Amazon's warehouses, constantly processing freight to provide customers with fast shipping. AWS even enables customers to tap into Amazon's AI capabilities to use in their own businesses.

The case for Alphabet

Alphabet is an attractive investment for several reasons. It owns a commanding 27% share of the digital advertising industry in 2023, enabling it to grow Q3 ad revenue to $59.6 billion from 2022's $54.5 billion.

But Alphabet also possesses leadership positions in other areas as well. YouTube is the biggest online video platform on the planet. As a result, YouTube brought in $8 billion in Q3 advertising revenue, a 12% jump over 2022's $7.1 billion. Now, Alphabet is working to build up YouTube's subscription revenue by adding popular content such as broadcasting NFL games.

Alphabet is also successfully growing a cloud computing business, Google Cloud, which saw Q3 revenue reach $8.4 billion from the prior year's $6.9 billion. Google Cloud is now the third largest cloud computing provider in the world.

The success of Alphabet's products helped it produce $76.7 billion in Q3 revenue, an 11% year-over-year increase. Its use of AI contributed to the company's growth. Alphabet uses AI to assist advertisers in creating and managing ads. And like AWS, Google Cloud enables businesses to adopt Alphabet's AI models in their own operations.

Deciding between Amazon and Alphabet stock

Given the success of Amazon and Alphabet's businesses, it's ideal to own shares of both companies. But it's worth noting the federal government is suing each for antitrust violations.

Amazon's case could take years to resolve. Alphabet's antitrust trial, however, is set to conclude in a few weeks. If the company is victorious, its share price might increase, while the opposite could happen with a loss. So for investors who are more risk averse, you may want hold off on an Alphabet investment until after a verdict is announced.

Yet the government's antitrust lawsuits haven't stopped the share price of both companies from going up in the first half of November. So if you could only invest in one of these tech titans, Alphabet is the better buy.

Alphabet doesn't have the overhead of Amazon, which must maintain warehouses and products, and deal with customer returns and shipping costs. In fact, through three quarters in 2022, Amazon suffered a net loss of $3 billion. This year, after cutting costs, Amazon's net income through three quarters was $19.8 billion. Contrast this with Alphabet's net income of $53.1 billion over three quarters in 2023.

Another factor is the difference between Amazon and Alphabet's free cash flow (FCF), an indicator of a company's ability to invest in its business, or enhance shareholder value through share repurchases. Alphabet generated $78 billion in FCF over the trailing 12 months, compared to Amazon's $21.4 billion over the same period.

Alphabet's far greater FCF generation gives the company plenty of cash to improve its business, including its AI investments. Considering these factors, Alphabet gains the edge as the better investment.