Walmart is partnering with China’s second largest e-commerce firm, JD.com, as it aims to take a larger bite out of the world’s most populous country.

In a wide-ranging alliance announced Monday, the U.S. retail giant said it has sold Yihaodian, its online commerce marketplace, to JD.com. Walmart will retain the Yihaodian direct sales business, but rather than operate its own online store entirely, it will become a retailer inside Yihaodian. It is also bringing its Sam’s Club membership service to JD.com, while Walmart’s physical stores will be listed on JD.com’s O2O JV Dada delivery platform.

On the financial side of things, Walmart is buying a five-percent stake in NASDAQ-listed JD.com, which is slowly increasing its marketshare and closing the gap on Alibaba. That investment is worth around $1.5 billion right now based on JD.com’s share price.

Walmart first invested in Yihaodian, which specializes in grocery and items focused on affluent female consumers — in 2011 and it bought the B2C service its entirety last summer: so why is it cutting a deal to get out of the business less than a year later?

The U.S. giant seems to have fully realized that the Chinese market is dominated by two major players, and it is seriously cutthroat.

Data from iResearch suggests that Yihaodian accounts for less than two percent of China’s e-commerce spending — Alibaba and JD.com are collectively over 80 percent — although Walmart claims the service is strongest in eastern and southern China. Based on that, it makes sense to lean on JD.com as the distribution partner to help grow its business in China.

The Wall Street Journal reported that one-third of the $482.1 billion in annual sales that Walmart makes outside the U.S. market comes from China, so the country is clearly still hugely important. It’ll certainly be interesting to see how it fares with JD.com, which differentiates itself from Alibaba by owning its own logistics and specializing in fast delivery and fresh goods.

It isn’t uncommon to see e-commerce players sell on rival platforms. Amazon opened a store on Alibaba’s Taobao mall last year, for example.

“JD.com shares similar values in making the lives of customers better. It also has a very complementary business and is an ideal partner that will help us offer compelling new experiences that can reach significantly more customers,” Doug McMillon, president and CEO of Walmart, said in a statement.