Walmart Inc. is ending cigarette sales in some U.S. stores after years of debate within the retail company’s leadership ranks about the sale of tobacco products, according to people familiar with the matter.

Cigarettes are being removed in various markets, including some stores in California, Florida, Arkansas and New Mexico, according to the people and store visits. In some of these stores, Walmart has rolled out a design with more self-checkout registers, as well as other items such as grab-and-go food or candy sold near the front of stores in place of Marlboro, Newport and other tobacco products.

Walmart, which has more than 4,700 U.S. stores, is removing tobacco products from select locations where the retailer has decided to use the space more efficiently, a spokeswoman said. “We are always looking at ways to meet our customers’ needs while still operating an efficient business,” she said. She declined to say how many locations will continue to sell cigarettes but said Walmart isn’t halting all tobacco sales.

The shift comes after years of internal debate at Walmart about cigarettes, which U.S. health officials say are linked to 480,000 deaths in the country each year and which are complex for big-box retailers to sell because of regulations. Top Walmart executives decided to start moving out of the category in some locations before the Covid-19 pandemic, some of the people said, a decision now playing out in stores.

Tension regarding the issue of cigarette sales has risen as Walmart works to become a larger player in healthcare.

Photo: Angus Mordant/Bloomberg News

For years Walmart Chief Executive Doug McMillon has challenged other executives to find a way to stop selling tobacco, without demanding that the company do so, according to people familiar with those discussions.

Tension around the issue has risen as Walmart works to become a larger player in the healthcare industry, say some of these people. Many top executives argued that cigarettes are legal products that customers want and that Walmart shouldn’t be in the business of morally policing its shoppers, according to some of the people.

As with tobacco, Walmart has pulled back on sales of firearms in recent years after similar internal discussions. It raised the age to purchase guns to 21 after the 2018 high-school shooting in Parkland, Fla., and discontinued sales of ammunition used in semiautomatic weapons and handguns after a 2019 shooting at a Walmart in El Paso, Texas.

At Walmart, sales of cigarettes are generally less profitable than some other items sold near the front of stores such as candy, according to the people familiar with the situation. It is also an operationally complex sale, eating into profits. Tobacco is kept in a locked case or blocked from shoppers. Food and Drug Administration regulations require that an employee make the sale. At Walmart, that employee must be over a specific age based on local laws and trained in tobacco sales. Theft is high throughout the supply chain, said some of these people.

Some retailers stopped selling tobacco products years ago. Target Corp. eliminated all tobacco sales in 1996. CVS Health Corp.

said that its decision in 2014 to stop tobacco sales would result in an estimated $2 billion loss in annual revenue but that those sales ran counter to the company’s goals as a healthcare provider.

U.S. cigarette sales totaled about $95 billion last year, and most of those purchases occur at gas stations and convenience stores, according to data from Euromonitor International. Walmart supercenters and other mixed retailers accounted for 14% of U.S. cigarette sales volume in 2020, according to Euromonitor.

The volume of cigarettes sold in the U.S. rose in 2020 during the pandemic, reversing a yearslong decline in smoking rates. In 2021, as pandemic restrictions ended and consumer mobility increased, U.S. cigarette industry sales fell 5.5%, according to Marlboro maker Altria Group Inc.

Shares of tobacco companies fell in Monday’s trading. Altria dropped 3% while British American Tobacco

PLC, which owns Reynolds, slipped 1.5%.

”Retailers have the right to choose what products they want to sell,” an Altria spokesman said. “We value the relationship we have with more than 200,000 retailers across the country.”

Walmart represents about 5% of U.S. cigarette sales volumes, Goldman Sachs analyst Bonnie Herzog wrote in a note Monday. She said Walmart’s decision shouldn’t make a dent in cigarette makers’ sales because shoppers would buy cigarettes elsewhere.

Walmart has backed away from some tobacco products in recent years. In 2019, Walmart said it would sell tobacco products only to people 21 or older in the midst of regulatory pressure to stop sales to minors. A federal law passed later that year raised the minimum tobacco-purchase age to 21 nationwide. Also that year, Walmart halted its e-cigarette sales, citing regulatory uncertainty around vaping.

Like other retailers, Walmart doesn’t sell tobacco in municipalities such as New York and parts of Massachusetts that won’t allow locations with retail pharmacies to sell tobacco. Sam’s Club, Walmart’s warehouse chain, started gradually stopping sales of cigarettes in 2018. Sam’s Club now sells tobacco products in fewer than 40 of its approximately 600 U.S. stores, a spokeswoman said.

In recent years, Walmart has focused on redesigning existing stores rather than building new ones. The redesign often includes adding more self-checkouts to save money on staffing. “When you had mostly self-checkouts, manned by one or two associates, tobacco became really problematic,” said one of the people familiar with Walmart’s business.

At the same time, Walmart aims to build a larger healthcare business. The company is one of the biggest pharmacy chains in the country. It is opening primary-care clinics, hosting wellness days that offer shoppers free health screenings and has administered millions of Covid-19 vaccines. Last year Walmart bough MeMD, a telehealth provider.

Write to Sarah Nassauer at sarah.nassauer@wsj.com and Jennifer Maloney at jennifer.maloney@wsj.com