SAN FRANCISCO — Google and Walmart are testing the notion that an enemy’s enemy is a friend.

The two companies said Google would start offering Walmart products to people who shop on Google Express, the company’s online shopping mall. It’s the first time the world’s biggest retailer has made its products available online in the United States outside of its own website.

The partnership, announced on Wednesday, is a testament to the mutual threat facing both companies from Amazon.com. Amazon’s dominance in online shopping is challenging brick-and-mortar retailers like Walmart, while more people are starting web searches for products they might buy on Amazon instead of Google.

But working together does not ensure that they will be any more successful. For most consumers, Amazon remains the primary option for online shopping. No other retailer can match the size of Amazon’s inventory, the efficiency with which it moves shoppers from browsing to buying, or its many home delivery options.

The two companies said the partnership was less about how online shopping is done today, but where it is going in the future. They said that they foresaw Walmart customers reordering items they purchased in the past by speaking to Google Home, the company’s voice-controlled speaker and an answer to Amazon’s Echo. The eventual plan is for Walmart customers to also shop using the Google Assistant, the artificially intelligent software assistant found in smartphones running Google’s Android software.