NEW YORK (AP) – Wal-Mart is selling its Chinese online business to the country’s No. 2 e-commerce site in a strategic partnership that it hopes will bolster its presence in the extraordinarily lucrative but increasingly competitive online marketplace.

The company said Monday it is giving JD.com ownership of its Yihaodian e-commerce site in China, including the brand and app. Wal-Mart’s Sam’s Club China will open a flagship section on JD.com, and both companies will leverage their supply chains and broaden the range of imported goods. Wal-Mart will take a 5 percent stake in JD.com, or nearly 145 million newly issued Class A shares in the company.

The move comes as Wal-Mart Stores Inc. is trying to improve its overall business in China, now the fourth-largest international market by sales. Business has been slow and uneven, and it operates just over 400 stores despite entering the country 20 years ago. It sees bolstering its online business as the future to growth in China.

Wal-Mart says it could see a tremendous amount of traffic from JD.com’s huge customer base and its same-day delivery network. JD.com has nearly 6,000 delivery and pickup stations in about 2,500 counties and districts across China. Yihaodian owns and operates only about 250 hubs.

Though JD.com’s strength is in brand-name electronics, it will be able to help capitalize on Yihaodian’s strong brand name and business in eastern and southern China and in important categories such as groceries and household goods.

Food is among the growing number of products that Chinese shoppers are increasingly migrating online to shop for, which is a big reason why traffic has declined at the company’s namesake stores in China as well as at its rival’s big stores. Sam’s Clubs in China, which number 13, has been a bright spot in the China business, as the company focuses on affluent Chinese shoppers who have been embracing Western ways of shopping. Wal-Mart has sought to establish itself as a source for high-quality food in the wake of a slew of safety issues in China, and has highlighted imported food to cater to middle-class shoppers looking for premium goods.

Wal-Mart previously had just 1.6 percent of China’s overall online market, ranking it No. 6 – well behind powerhouse Alibaba’s 46.9 percent and JD.com’s 20.1 percent, according to research firm Euromonitor International. The research firm excludes consumer-to-consumer selling. Wal-Mart had been fighting Alibaba, JD.com, and a swarm of smaller, online food sellers.

In a statement issued Monday, Wal-Mart Stores Inc. CEO Doug McMillon said JD.com has a “very complementary business and is an ideal partner.”

Getting China right is key to strengthening Wal-Mart’s global online business, which has seen sales growth slow. Wal-Mart said recently that global e-commerce sales rose 7 percent in the first quarter, weaker than the 8 percent in the previous quarter and far below the 20 percent increases seen less than two years ago. It highlighted stiff challenges not only in China, but in Brazil and the United Kingdom as well.

The retailer took full control of Yihaodian last July after its first investment in the company in 2011 as it seeks to catch up in China, which has a massive potential customer base in the world’s largest online marketplace. Since then, Wal-Mart has been trying to accelerate the integration of its online business and physical stores in China. It launched an app last year that lets shoppers order online and pick up goods at the stores in several southern cities.

Last August, JD.com announced that it would acquire a 10 percent stake in Chinese store rival Yonghui, which has an expertise in fresh food. In December, it launched a service that allows shoppers to order groceries and fresh food to their home within two hours. That’s now available in about 60 Yonghui stores.

Shares in JD.com surged 8 percent before trading was halted Monday.