The biggest company in the world has a chip on its shoulder right now—and that’s probably a good thing. Why? The ever-growing challenge from online retailers is pushing Walmart to be a much better operator in the digital world.

“For us, a big part of it is being paranoid,” said Walmart chairman Greg Penner on Thursday at the Fortune Global Forum in Guangzhou, China. “We’re at our best when we’ve got a competitor that’s really challenging us.”

If so, the mega-retailer is doubly blessed: It now has two mammoth online retailers targeting its core business.

For quite some time, Walmart, No. 1 on Fortune’s Global 500 list of the world’s largest companies with $486 billion in sales last year, has been working to adjust its strategy to reckon with the threat posed by Amazon.com.

The so-called Everything Store had more than 50% of all online retail sales in the U.S. last year and continues to expand at a blistering pace. With its acquisition earlier this year of Whole Foods, Amazon served notice that it is bringing the fight for consumers to Walmart on its own turf—physical stores. Amazon’s market value has risen above $550 billion, significantly above Walmart’s stock market value of around $290 billion despite strong returns for Walmart’s shares this year.

In China, Walmart now has another potent competitor getting into the stores business: Chinese online retail titan Alibaba.

Alibaba announced in November that it was investing $2.9 billion to acquire a 36% stake in Chinese hypermarket operator Sun Art, which has some 400 stores in China similar in scale to Walmart’s superstores. As with Amazon and Whole Foods, Alibaba plans to create a connected retail experience for shoppers between their smartphones and their neighborhood stores.

It’s the same strategy Walmart is pursuing, but in reverse: Amazon and Alibaba want to bring their huge customer bases into stores; Walmart wants to persuade the shoppers who frequent its nearly 12,000 stores globally to do more of their digital shopping with Walmart as well.

The retail business is no longer bifurcated between physical and digital, said Penner. The best way to win customers in the future is going to be by offering a sophisticated mix of both options.

“Customers aren’t going to care where products came from,” said Penner. “They just want a seamless experience. So that’s what we’re trying to solve for.”

Walmart has made significant digital inroads since its acquisition of Jet.com last year. In its most recent quarter, the company grew its online sales by 50%. Walmart.com now sells some 70 million items—triple its number of offerings a year ago.

Penner told the audience at the Fortune Global Forum that the deal allowed the company to scale up faster. It can now reach 90% of consumers in China, he said. And shoppers can order items on the JD.com platform, have them picked from shelves in Walmart’s stores, and delivered within an hour.

“We went all in with that strategy,” said Penner. “We just felt we had to be part of a bigger ecosystem.”

Alibaba’s latest move presents a big, new challenge to Walmart’s business in the Chinese market—and more of the adversity that Penner says the company thrives on.