Flipkart -- which sells electronics, large appliances, mobile phones, apparel and more -- has the largest e-commerce players locally since its launch in 2007, with local rivals like Snapdeal helping draw more customers into online shopping.

The deal for 77 percent of Flipkart gives Walmart, the biggest retailer in the world, a front-row seat to the rapidly growing e-commerce market in India, the second most-populous country in the world. It's also a new battlefront against Amazon, which has been pouring billions of dollars in investment into India to grow there since it opened an India site in 2013. Amazon reportedly made a rival bid for Flipkart, but Walmart beat it to the punch.

"India is one of the most attractive retail markets in the world, given its size and growth rate, and our investment is an opportunity to partner with the company that is leading transformation of e-commerce in the market," Walmart CEO Doug McMillon said in a statement.

Meanwhile eBay, which sold its local business to Flipkart last year, said Wednesday it's unloading its minority stake in Flipkart for about $1.1 billion. After the deal closes, eBay said it plans to relaunch eBay India, with a focus on cross-border trade.

The deal, which is expected to close later this year, would give Walmart another tool in its fight against Amazon. In 2016, Walmart spent $3.3 billion to buy Jet.com in the US. So far, Walmart has seen growth in its online sales, but it remains a much smaller player in the US compared with Amazon, which takes up an outsized 40 percent of online sales in the country.

In India, Walmart doesn't have a major footprint. It operates 21 Best Price cash-and-carry stores and one fulfillment center.

The rest of Flipkart's business that Walmart won't be buying will be held by some of Flipkart's existing shareholders, including Flipkart co-founder Binny Bansal, Tencent Holdings, Tiger Global Management and Microsoft.

Walmart said its immediate plan is to focus on growing Flipkart's business, but it supports the company's ambition to become a publicly listed subsidiary in the future.