Amazon (NASDAQ:AMZN) will close its domestic marketplace in China in July, ending a tough 15-year battle against Alibaba (NYSE:BABA) and JD.com (NASDAQ:JD) in the world's most populous country. Amazon China will stay online, but the marketplace will only sell products from third-party merchants from other countries.

Amazon will also keep selling its Kindle e-readers, online content, and AWS (Amazon Web Services) cloud services in China. Amazon isn't completely giving up on China, but its attempt to build a first-party marketplace -- which requires it to take possession of chinese products and fulfill orders with its own logistics network -- no longer seems worthwhile.

Why couldn't Amazon crack the Chinese market?

Amazon couldn't gain ground in China because JD and Alibaba claimed the e-commerce market first. JD was founded in 1998, and its first e-commerce marketplace went online in 2004. Like Amazon, JD used a business-to-consumer (B2C) model in which it fulfilled most of its own orders.

Alibaba was founded in 1999, and launched its Taobao marketplace in 2003. Taobao uses a consumer-to-consumer (C2C) business model that more closely resembles eBay's rather than Amazon's. In 2008, Alibaba launched Tmall, a spin-off B2C marketplace that let businesses sell higher-end products. Unlike JD, Alibaba mainly relies on third-party courier services to fulfill its orders.

Amazon entered China in 2004 by acquiring the online bookstore Joyo.com for $75 million. Unfortunately, Joyo was dwarfed by JD and Alibaba, and big investments and a rebranding from Amazon didn't help it gain much traction. Amazon also couldn't fulfill orders as quickly as Alibaba or JD, and the Chinese version of Prime, which launched in 2016, lacked streaming content.

Amazon China only accounted for 0.7% of all e-commerce sales in China last year, according to eMarketer. Alibaba's marketplaces claimed 58.2% of the market, and JD ranked second with a 16.3% share. The rest of the market was fragmented among smaller players with single-digit market shares.

When Amazon opened an online store on Tmall in 2015, it was clear that Amazon China's days were numbered. The following year, Walmart (NYSE:WMT) exchanged its Chinese online marketplace for a stake in JD. Those moves indicated that it was nearly impossible for Western e-commerce players to crack the Chinese market.

Amazon
Empty boxes are stacked in the packaging department at the Fulfilment Centre for online retail giant Amazon in Peterborough, central England, Nov. 28, 2013. ANDREW YATES/AFP/Getty Images

Focusing on India instead

Alibaba and JD's year-over-year sales growth also decelerated in recent quarters as the Chinese economy slowed down. If the market leaders are struggling, underdogs like Amazon China will likely fare even worse. China isn't one of Amazon's top markets (currently the U.S., Germany, the U.K., and Japan), so shuttering Amazon China's domestic marketplace shouldn't hurt its long-term growth.

Therefore, it makes sense for Amazon to scale back its investments in China, close some fulfillment centers, and focus on more promising markets like India, which has a faster growing economy and the second largest population in the world. Morgan Stanley expects over half of India's internet users to make online purchases by 2026, compared to just 14% in 2016.

Amazon and Walmart's Flipkart are currently the country's two largest e-commerce players. Amazon allocated $5 billion to its expansion in India three years ago, and a retreat from China could free up more resources to challenge Flipkart in India. Amazon is currently expanding its brick-and-mortar presence with over 100 mall kiosks across India to counter the pressure from new regulations that ban online retailers from offering exclusive sales, selling products in which they own equity interest, and offering special discounts or cashback offers.

Is this the end of Amazon in China?

Amazon won't disappear from China, but its remaining businesses face tough competition. Amazon's plan to keep selling overseas products from third-party sellers faces stiff competition from Alibaba's AliExpress and JD Worldwide, which both facilitate cross-border transactions.

Alibaba Cloud is also China's largest cloud platform by a wide margin according to IDC, while AWS (Amazon Web Services) remains an underdog. Meanwhile, Amazon's Kindle faces tough competition from domestic devices like Tencent's QQ Reader. If Amazon reduces its investments in China, these businesses could be overrun by their domestic rivals in the near future.

This article originally appeared in the Motley Fool.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Leo Sun owns shares of Amazon, JD.com, and Tencent Holdings. The Motley Fool owns shares of and recommends Amazon, JD.com, and Tencent Holdings. The Motley Fool recommends eBay. The Motley Fool has a disclosure policy.