SAN FRANCISCO (Reuters) - Apple Inc, the world’s most valuable publicly listed company, is in danger of being beaten by Amazon.com Inc to the $1 trillion mark.

Wall Street’s optimism about last year’s 10th anniversary iPhone had propelled Apple’s stock 24 percent higher over the past 12 months, giving it a market capitalization of $893 billion.

That is $141 billion more than the $752 billion market value of Amazon, the world’s third most valuable publicly listed company, but Amazon has been quickly closing the gap.

(For graphic on Market Capitalization: Apple vs Amazon.com vs Alphabet, click: reut.rs/2Fn9hzA)

Amazon’s stock has surged 83 percent over the past year, bolstered by scorchingly fast revenue growth as more shopping moves online and businesses shift their computing operations to the cloud, where Amazon Web Services leads the market.

In January, Amazon announced that it, Berkshire Hathaway Inc and JPMorgan Chase & Co would form a company to cut health care costs for their employees, which was widely seen as a threat to the existing U.S. healthcare system and underscored Amazon’s ability to disrupt markets.

Amazon dislodged Microsoft Corp as the No. 3 U.S. company by market capitalization in February.

FILE PHOTO: The Amazon logo is seen at the Young Entrepreneurs fair in Paris, France, February 7, 2018. REUTERS/Charles Platiau

At $783 billion, Alphabet Inc has the second largest market capitalization. The Google parent company’s stock has grown about 33 percent over the past year, faster than Apple but far slower than Amazon.

Meanwhile, optimism about Apple’s iPhone X has given way to concerns that demand for the $1,000 device may be weaker than expected.

To be sure, past stock gains are not a reliable predictor of future performance, and the surge in Amazon shares in recent years has been exceptional by most standards.

But if Amazon’s stock were to keep growing on the trajectory seen over the past year, the company’s market capitalization would hit $1 trillion in late August. Apple would reach $1 trillion around a week later if its stock price continued to rise at the same pace seen over the past year.

Alphabet would not reach $1 trillion until 2019 if its stock price continued to rise at the same pace seen over the past year.

(For graphic on race to $1 Trillion Market Cap, click: reut.rs/2DbhQYq)

Most Wall Street analysts are not quite that enthusiastic about the growth of Apple and Amazon. Analysts on average expect Apple’s stock price to rise 11 percent and reach $195 within the next 12 months, which would put its market capitalization at $989 billion, according to Thomson Reuters data.

Analysts covering Amazon on average expect its stock to rise 10 percent within the next year to reach $1,700, which would give it a market value of $823 billion.

Apple on Thursday was up 0.60 percent at $176.05, while Amazon rose 0.31 percent to $1,549.90.

(For graphic on Analyst Price Targets: Apple Vs Amazon Market Cap, click: reut.rs/2FtMBtO)