Wal-Mart Stores Inc. signed a $3.3 billion deal to buy web retailer Jet.com Inc., bringing in some outside help to jump-start growth at the retail giant’s e-commerce operations.

The deal is the largest ever purchase of a U.S. e-commerce startup and a sign Wal-Mart Chief Executive Doug McMillon sees the shift to online shopping and the expansion of Amazon.com Inc. as existential threats to the company’s five decades of growth.

Jet’s...