In September 2016, Walmart made a giant, risky bet.

The country’s most dominant brick-and-mortar retailer agreed to the largest-ever acquisition of an e-commerce company: a $3.3 billion purchase of a fast-growing but money-sucking online shopping site called Jet.com.

There were no other bidders for Jet back then, but Walmart was desperate to close the huge gap between itself and Amazon, the online shopping wrecking ball. And CEO Doug McMillon had become convinced that Jet founder and CEO Marc Lore, who previously founded Diapers.com and sold it for a fortune to Amazon, was perhaps the only person who could do it.

Nearly three years later, Walmart’s stock price is up 53 percent, compared to a 38 percent increase for the S&P 500 over the same period of time.

The company’s US online sales increased 40 percent last year, buoyed by a successful expansion of an online grocery business; the digital-first brands and digital-first talent it has acquired have breathed new life into its portfolio; and it has shed at least part of its reputation for being a digital dinosaur.

Walmart is, by most measures, in a more competitive position than it was before it acquired Jet.

But it’s still far behind Amazon, and inside Walmart, tensions are rising. Multiple sources tell Recode that the company is projecting losses of more than $1 billion for its US e-commerce division this year, on revenue of between $21 billion and $22 billion. Walmart does not disclose these figures publicly and declined to comment.

That size loss is an eye-popping figure for a company that is used to printing cash and that prides itself on its profitable operations; the overall Walmart business brought in nearly $7 billion in profits during the last fiscal year.

And CEO Doug McMillion and Walmart’s board of directors are not happy about it. So they are increasing pressure on Lore and his online business to cut losses, multiple sources told Recode, which will likely result in selling off at least one online fashion brand, ModCloth, which it purchased just a few years ago.

To make matters worse, the executive team that leads Walmart’s core business in the US — physical stores — is increasingly frustrated by some of the money-losing initiatives, and sources say its leader is perturbed by the credit Lore’s division gets in the media and on Wall Street for the success of Walmart’s growing online grocery business.

While this strained dynamic inside Walmart is not unheard of for a well-established company attempting to navigate big, technological disruption, the stakes are huge and the company cannot afford the delays that typically result from infighting.

Amazon now accounts for nearly 38 percent of online retail in the US, up from 32 percent in 2016, according to an estimate from eMarketer. Walmart, on the other hand, accounts for just 4.7 percent, up from 2.6 percent three years ago.

While e-commerce still only represents 5 percent of Walmart’s entire US business, it represents where the industry is moving.

This is the reality Lore is still struggling to get Walmart’s entire executive team and board to accept, though sources say McMillon also acknowledges it: E-commerce in the US is becoming a “winner take all” industry. Or, at a minimum, a “winner take most” market.

Amazon is a very real existential threat to Walmart’s entire future if the retailer does not significantly close this gap — and fast. If Walmart falls further behind Amazon or doesn’t make up ground, we’re increasingly likely to face a future where Amazon is even more the de facto online store for everyone, with little legitimate competition or compelling alternatives on the market.

Money-losing is not the Walmart way

So Walmart is in full catch-up mode just to make a dent in Amazon’s lead.

Lore has aggressively pitched the company’s management and board on the idea that Walmart needs to spend billions a year on new warehouses if it’s going to seriously compete online with “the Everything Store” and its speedy delivery offerings, sources say.

Amazon has 110 fulfillment centers in the US, while Walmart has 20 at most. Walmart’s in-store selection is also not large enough to use stores to fulfill online general merchandise orders at a scale that would rival Amazon’s product catalogue.

The problem is that building the online version of the Everything Store requires millions more products, and that means two things that Walmart’s current infrastructure does not support: dozens more e-commerce warehouses and a lot more merchants and brands selling through Walmart.com.

The former is mainly a cash problem. As in, you need to spend a lot of cash to build a warehouse network to rival Amazon’s. But Walmart has not secured the same trust — and long leash — from Wall Street investors that Amazon has.

Amazon, on the other hand, has literally been building out its warehouse infrastructure for two whole decades, and it can offset its losses from expensive investments via high-profit businesses like Amazon Web Services and its fast-growing advertising business.

Adding more selection certainly involves hiring more corporate employees to source tons of new brands, but it also requires the infrastructure to be able to keep the quality of products high while rapidly expanding selection. And that’s not an easy proposition, as Walmart has found and as Amazon certainly has too.

Walmart has mostly rebuffed Lore’s entreaties for huge new warehouse spending, in part because of how much deeper into the red the investments would put the e-commerce business over the next few years.

But sources say the company recently did agree to some investments that would expand and improve current e-commerce warehouses, while possibly adding more new facilities. The timing is important because Walmart recently announced a push to offer free, next-day shipping on a curated selection of up to 220,000 items — with no membership fee.

That followed an Amazon announcement a few weeks earlier that the standard shipping speed for Amazon Prime members, who pay $119 a year for a membership, would soon decrease from two days to one day. Amazon says that shipping speed will be available on more than 10 million products, dwarfing Walmart’s selection.

Walmart has added more than 2,000 new brands to its website over the past year, in part through acquisitions of online specialty retailers.

“It’s taking longer than I thought it was going to,” McMillion told analysts in October of the e-commerce unit’s profitability, “and I have been surprised at just how many brands there are out there to get signed up. ... Who knew we needed 2,000 of them. I didn’t.”

Even so, there is still a huge online selection gap between Amazon and Walmart, and it’s a critical reason for Amazon’s success.

First, the wider the selection, the more types of orders a customer can depend on Amazon for, and thus the more frequently they shop on Amazon.

Second, online retailers like Amazon and Walmart can typically squeeze more profits from lower-volume goods, such as an obscure book, a generic Halloween mask, or an air filter — what is referred to in the retail industry as the “long tail.”

While big retailers beat each other up on price for the most popular and oft-purchased items, like name-brand diapers or toothpaste, they often have more wiggle room on profits in the long tail. And Amazon’s long tail is millions of products long.

How Walmart’s next-day delivery push will impact profitability remains to be seen. At least initially, a large percentage of products available for next-day delivery consist of those that would be unprofitable if they were ordered on their own, two sources told Recode. That might also be true for Amazon, but Amazon has Prime members’ annual membership fee to help cover shipping costs.

Walmart is hopeful that the $35 minimum order threshold it has set for its free, next-day delivery program will lead to multi-item orders, which have a better shot at creating a profitable order. And that explains why Lore has publicly said that next-day shipping can actually help profits, because multi-item orders will typically now come in one box from the same warehouse, rather than from several, saving the company on shipping costs in the process.

Selling off new assets

The push to rein in losses has also forced Lore to reevaluate some of his division’s non-core, money-losing businesses. As a result, Walmart will likely sell at least one of the three digital fashion brands the company has bought under Lore.

Lore has overseen the acquisitions of the menswear brand Bonobos for $310 million, the vintage-style clothing brand ModCloth for less than $50 million, and, most recently, the women’s plus-sized fashion brand Eloquii for $100 million. Part of the thinking was that those deals would give Walmart and its online stores exclusive merchandise that shoppers can’t find on Amazon, which could help the Middle America retail giant appeal to a new generation of consumers who typically wouldn’t shop at Walmart.

But all three businesses are still unprofitable, sources say. And in recent months, Walmart has discussed the potential sale of both Bonobos and ModCloth to separate outside buyers, according to multiple sources familiar with the discussions.

ModCloth will likely be sold this year, these people said, and almost certainly for less than what Walmart paid for it. On the other hand, Walmart plans to hang on to Bonobos, after contemplating a sale but deciding against it.

The decision to sell ModCloth appears to stem from a realization that Walmart is going to be unable to turn around the company’s economics in the near term. The company was not performing well before the acquisition, and the business has not improved dramatically since.

The Bonobos talks, on the other hand, started after a private equity firm expressed unsolicited interest in purchasing the brand, two sources said. Walmart engaged in some discussions but ultimately decided against a sale.

Either way, Walmart has decided to stop purchasing digital-native brands for at least the next year, according to three sources, barring an incredible acquisition opportunity that is just too good to pass up. Buying these brands was part of Lore’s vision for how Walmart would differentiate from Amazon, so this shift is more evidence that some of his plans aren’t working out how he and Walmart had hoped.

Walmart does plan to continue to incubate its own brands, but with a focus on ones that are natural fits to be sold on Walmart.com and at Walmart stores. The company launched a mattress brand, Allswell, last February in both Walmart’s physical and digital storefronts, to compete with other bed-in-a-box brands like Casper and Tuft & Needle. The company has also been working on a new beauty brand, but it is unclear when or if it will launch publicly.

On the other end, no Bonobos, ModCloth, or Eloquii products are sold on Walmart.com or in Walmart’s stores. These brands are sold on Jet.com, but Walmart continues to deprioritize the shopping site Lore founded and to scale back its ambitions. Walmart has significantly cut the marketing dollars it spends on Jet since the acquisition, as well as the geographic markets in which it promotes the shopping site. And Lore announced last month that Jet’s president would be leaving the company and that the Jet team will be folded into the larger Walmart organization.

Internal tensions

All the while, the relationship between Lore and Walmart US CEO Greg Foran has soured, according to two sources familiar with the dynamic. One sore spot is the online grocery business. Foran is miffed by the public credit that Lore’s division gets for the growth of the service, which involves shoppers placing orders online but picking them up curbside at one of 2,000-plus stores after they are picked out by Walmart store employees. The program launched before Walmart acquired Jet.com.

“Greg and Marc started out in a good place,” one person familiar with the dynamic told Recode. “But over time, it’s very hard to be the person running a huge part of the organization that’s printing all the cash and get no public credit.”

The two leaders have also had strategic disagreements over the size of the losses that Lore’s online businesses are racking up in the US, and how resources could otherwise be allocated to moneymaking initiatives inside Walmart’s physical stores. Foran would prefer more resources go toward initiatives with clearer payoffs, like cutting in-store prices, multiple sources told Recode.

Foran and some members of his leadership team have also been frustrated by some of the company’s money-losing forays into building in-house startups that seem unlikely to ever reach mass scale or grow large enough to move the needle for Walmart’s overall business.

Walmart launched an incubation arm, called Store No. 8, under Lore, and one of its in-house startups is Jetblack, a Walmart-incubated personal shopping service initially targeting affluent moms that is only available in New York City. Members pay $50 a month to be able to order a wide range of products day and night — via text message — with no added delivery fee.

Lore recently commented that Jetblack customers spend on average $1,500 a month through the service, but Walmart has not released any information about how many customers the startup is serving or disclosed any financial metrics.

“The whole Walmart culture is to be humble, so all these startup announcements are countercultural in Bentonville,” one source said.

One other factor to keep in mind, though it’s unclear if it contributes to the Foran-Lore tension: In past years, Foran’s annual performance bonus has been heavily tied to the operating profit of Walmart’s US business, which includes the e-commerce division that Lore runs. Walmart’s US operating profit hasn’t, however, factored into Lore’s annual bonus.

Either way, the politics and push-pull has worn Lore down, according to three people who know him well.

Lore still largely has McMillon’s support, but the entrepreneur has not previously had a boss for this length of time since at least the early 2000s.

All three sources told Recode that they do not know for sure whether Lore will stay at Walmart for the full five years — through the fall of 2021 — that he agreed to at the time of the acquisition. But all three said they would be surprised if he does.

“The public narrative is basically that Marc is boosting the top line and hitting all these numbers,” one of these people said. “But then you talk to people internally and it’s doom and gloom. He’s suffering.”

Still, a person familiar with Lore’s thinking said the e-commerce executive fully intends to keep his commitment to stay at Walmart for least five years. Among the reasons: a sense of loyalty to McMillon.

But he has other good reasons, too. Entering this fiscal year, Lore was still owed $291 million in cash from the acquisition over the next three years, as well as shares of Walmart stock that’s valued at nearly $300 million today.

What’s next

Some inside Walmart would like the company to lean even harder into its digital strength: its grocery business. By the end of this year, Walmart says it will offer grocery pickup from 3,100 stores across the US and same-day grocery delivery from 1,600 stores. Walmart also plans to soon restart an experimental service where it will deliver groceries to someone’s home and actually load up the customer’s fridge when they get there.

Executives in this camp believe Walmart doesn’t need to match Amazon blow for blow when it comes to the size of its online product catalog, as long as Walmart builds a larger online grocery business than Amazon does.

Such an approach would resemble in some ways what Target has done: differentiate in one way, and then scale back the ambition of building the Everything Store online. In Target’s case, it differentiates itself through a growing assortment of exclusive in-house lines like the kids’ clothing brand Cat & Jack and the women’s apparel brand A New Day. Both now register more than $1 billion in sales annually and are only sold at Target stores and on Target.com.

The company is also fulfilling more than 80 percent of Target.com orders from its stores, meaning both that Target doesn’t need a ton of expensive warehouses and also that it is okay selling mostly the products that can fit in those stores.

The problem with a similar approach for Walmart is that investors are likely to punish it if it invests too much in the future, but they are bound to also disapprove if Walmart greatly scales back its overall ambition. That mainly has to do with its size: In the past fiscal year, Walmart’s US business had revenue of more than $330 billion. Target’s revenue, on the other hand, was a fraction of that at $75 billion.

In the end — whether Lore stays or goes, whether Walmart management and its board come to a better alignment on how aggressively to challenge Amazon or not — one counterintuitive thing is for sure: Amazon actually needs Walmart to be a strong No. 2 competitor in online commerce.

That’s because politicians and the Federal Trade Commission are already asking tough questions about Amazon’s business practices and market power. How much more intense would the scrutiny get if it became clear that even Walmart, with its history and its own market power, didn’t stand a chance against Amazon?

Recode and Vox have joined forces to uncover and explain how our digital world is changing — and changing us. Subscribe to Recode podcasts to hear Kara Swisher and Peter Kafka lead the tough conversations the technology industry needs today.