When Walmart first announced its big-bang entry into India in 2007, it had grand plans to have its huge signature stores sprinkled across the country. Almost a decade later, the reality looks very different.

On May 9, Walmart announced that it has acquired a 77% stake in India’s largest e-commerce firm, Flipkart, for $16 billion (Rs 1.06 lakh crore). The deal will give the American retailer a direct link to a market that is expected to be worth $200 billion by 2026.

“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 the transformation of e-commerce in the market,” said Doug McMillon, Walmart’s president and chief executive officer, in the statement. Flipkart’s existing shareholders, including co-founder Binny Bansal, Tencent Holdings, Tiger Global Management and Microsoft Corp will continue to hold a stake in the company.

So far, the retail giant from Arkansas just had a foot in the door with 21 cash-and-carry wholesale outlets, mostly on the fringes of the big cities in Asia’s third-largest economy.

A decade in waiting

The Indian government does not allow foreign multi-brand giants like Walmart to open front-end stores in the country on their own. That is why the American retailer had entered into a joint venture with telecom major Bharti Enterprises in 2007 to create Bharti-Walmart.

The plan was simple: Walmart’s cash-and-carry stores would supply to Bharti Retail, the retail subsidiary of Bharti Enterprises, which would be the consumer-facing end of the business. These stores would also service small businesses and mom-and-pop shops. Walmart would also provide infrastructure and technical support, and bide time till India allowed foreign retailers to set up fully-owned retail stores.

In 2009, Bharti-Walmart’s first store came up in the northern India city of Amritsar. And over the next eight years, Walmart added some 20 more stores here.

But foreign retailers are still not allowed to fully invest in opening supermarkets in India. Foreign investors are, however, allowed to invest in India’s e-commerce marketplaces that sell goods from various sellers.

The downers

Walmart’s failure to make a splash in India was not for a lack of trying.

In 2012, disclosures by the company saying that it had spent $25 million on lobbying the Indian authorities to open up investments in retail caused much furore.

Then, there was an alleged bribery scandal that was unearthed in Mexico back in 2012. Walmart soon extended the probe into the scandal to India, China, and Brazil. These controversies did not help the retailer’s image.

All this eventually led to the suspension of the company’s top officials in India, including its chief financial officer, as well as severed ties with its local partner, the Bharti group, in October 2013.

Despite the downers, Walmart stayed its ground. “India was the next big market for the company and they wanted to participate in a big way (here),” said a former employee on the condition of anonymity. “They have invested way too much here already to pack up and leave.”

“Secret” e-commerce plan

Between building a wholesale business and waiting for the FDI policy to open, Walmart toyed with a business-to-business e-commerce venture in its early years here.

In 2010, the company set up a separate e-commerce team headed by Dippankar Haldar – a former chief executive of now shut grocery store chain Spinach Retail – who spent close to two years researching technologies that would enable e-retailing in India. Bharti-Walmart even roped in technology giant IBM to help it with its retail support.

“It was a secret project. The plan was that Walmart would use the e-commerce platform for its wholesale business and Bharti would use it to get its stores online,” said a person familiar with the company’s plans, requesting anonymity.

But the project was shelved in 2012, amid growing troubles in its retail joint venture with Bharti. Its then chief executive, Raj Jain, was reportedly wary of pushing an online business here.

Later in 2014, when its tie-up with Bharti had ended, Walmart opened up its cash and carry business to online buyers.

That ambition has now come to fruition with the Flipkart deal.

Is this the dream?

Walmart’s investment in Flipkart comes at a time when India’s e-commerce industry is growing rapidly. By 2026, online retail is expected to account for 12% of the country’s overall retail market, from just 2% in 2016, as per Morgan Stanley.

Traditionally a brick-and-mortar retailer, Walmart is moving online even on its home turf, as consumers spend more time and money online. The company has been ramping up its online business in the US through an acquisition spree, and has also doubled down (pdf) on the number of products sold on Walmart.com in the US.

Besides the US, the retailer is pumping investments in e-commerce in China, Mexico and Canada. In China, where the retailer has over 440 stores, it bought a 5% stake in JD.com, the second-largest online retailer in the country, in 2016. India has now made it to this list.

“Walmart needed Flipkart possibly more than Flipkart needed Walmart,” said Yugal Joshi, practice director at management consulting and research firm Everest Group. “It didn’t have any shortage of funds and Softbank and others were really invested. It is a strong sign that a global giant found an Indian startup so important for its own online survival in the online market.”

Ananya Bhattacharya contributed to this story.

This article first appeared on Quartz.