The world’s biggest retailer has concluded it can’t take on the whole world by itself.

Walmart Inc. is in discussions to give up control over hundreds of stores in the U.K. and Brazil, two big markets where it has struggled for years, according to people familiar with the talks. At the same time, it is preparing to pour billions of dollars into an Indian e-commerce startup to crack a promising market that has long eluded the U.S. giant.

After...