Move over, Jeff Bezos: Jack Ma's Alibaba could soon reclaim the title of world's most valuable online retailer.

Alibaba's stock rose nearly 5% to an all-time high on Thursday after the company reported sales and profits for its second quarter that easily topped Wall Street's forecasts.

Shares of Alibaba (BABA) have surged more than 90% this year, and the company is now worth about $420 billion. That puts its closer to Amazon (AMZN), which is having a pretty good year as well. It is worth $465 billion, following a 30% pop in its stock this year.

But Alibaba, which owns the Chinese e-commerce sites Taobao and Tmall, has outperformed Amazon thanks to strong demand in its home market. Alibaba said total revenue was up 56% from a year ago, led by a big jump in mobile users.

Alibaba is also benefiting from booming demand in its cloud business. Alibaba, like Amazon, hosts online commerce sites for other companies. Revenue from that unit nearly doubled from a year ago.

And Alibaba, under the direction of enigmatic founder Ma, is also moving to make the company more diversified like Amazon. It owns the YouTube-like video site Youku Tudou and the South China Morning Post newspaper.

If Alibaba's stock continues to climb and it passes Amazon in market value, it won't be the first time.

Related: Trump vs. Amazon: So much for the businessman president

Alibaba was worth more than $230 billion when it went public in September 2014. Amazon's market value was hovering around $150 billion at that time.

But Alibaba's stock took a hit in 2015 because of concerns about the proliferation of counterfeit goods on Alibaba sites.

Meanwhile, Amazon kept powering ahead. It's only been recently that both Amazon and Alibaba have been marching higher again in lockstep.

Even as they dominate online retail, the companies each face growing competition from the likes of China's JD.com (JD) as well as Walmart and Target in the U.S. Walmart (WMT)and Target (TGT) reported strong gains in digital sales when they posted their most recent earnings this week.

Walmart in particular is making a much bigger push for online shoppers with the purchase of Jet.com and several other specialty e-commerce sites.