By Dave Sebastian

Walmart Inc. will require customers to wear face coverings inside all of its U.S. Walmart and Sam's Club stores starting July 20, becoming the largest company to impose restrictions amid a surge in coronavirus cases in several U.S. states.

Walmart follows a handful of national chains -- including Best Buy Co., Starbucks Corp. and Costco Wholesale Corp. -- to require face masks as companies try to protect its staff and customers against the pathogen.

About 65% of Walmart's more than 5,000 locations are in areas where a government mandate on face coverings is in place, said Dacona Smith, operating chief of Walmart U.S., and Lance De La Rosa, Sam's Club chief operating officer.

There is widespread scientific and medical consensus that face masks are critical in slowing the virus's spread. Questions over wearing them have fueled heated political debates in the U.S. and led to sometimes violent confrontations between retail workers enforcing mask rules and customers who refuse to cover their face.

A patchwork in the U.S. of rules and regulations around their use has led to varied policies among the nation's biggest retailers. Most major companies, from big-box retailers to pharmacy chains, require masks in places where state or local governments say they are mandatory. Some of those companies prohibit patrons from entering without a mask, while others request customers wear one but will still allow them in if they refuse.

Walmart said it will have staff members near the entrance to remind visitors who aren't wearing a mask and hand out free masks to those who didn't bring one. "Our associates will be trained on those exceptions to help reduce friction for the shopper and make the process as easy as possible for everyone," Messrs. Smith and De La Rosa said.

Stores will have a single entrance to ensure the requirement's consistency.

Write to Dave Sebastian at dave.sebastian@wsj.com