Dick’s Sporting Goods (NYSE: DKS), one of the nation’s largest sports retailers, has announced that it is immediately changing some of its policies related to gun sales. The company will no longer sell any gun to anyone under 21 years of age, regardless of local laws. The retailer also said that it would no longer sell high-capacity magazines.

Dick’s is also immediately ending sales of all assault-style rifles in its stores. The company said that the AR-15-style and other semiautomatic rifles will no longer be sold in its 35 Field & Stream stores or on its websites. The company said that it had not decided what to do with its inventory of assault-style rifles, but they would not be sold in the marketplace. Dick’s will continue to sell a variety of sport and hunting firearms.

The announcement was made two weeks after a school shooting in Parkland, Florida killed 17 students and staff members. After the shooting, the retailer reviewed its purchase records and found that it had legally sold a gun to the accused Parkland killer, Nikolas Cruz, in November. The gun sold by Dick’s was not the type used in the school shooting, but the coincidence alarmed Edward Stack, the chief executive of Dick’s.

Mr. Stack said in an interview, “It came to us that we could have been a part of this story. We said, ‘We don’t want to be a part of this any longer.’” All of the company’s top executives and its directors backed the decision to take a stand, he said. Mr. Stack added, “We’re going to take a stand and step up and tell people our view and, hopefully, bring people along into the conversation.”

Dick’s removed assault-style rifles from its main stores after a gunman killed 26 people at Sandy Hook Elementary School in Newtown, Connecticut, but then brought them back at its outdoor and hunting retail chain, Field & Stream, a few months later. Mr. Stack says that this time, the changes will be permanent.

A spokesman for Dick’s said the company had received an overwhelmingly positive response to its decision. The action is one of the strongest stances taken by corporate America on guns. The company is also calling on elected officials to pass what it refers to as “common sense gun reform,” which includes raising the minimum age to buy guns to 21, conducting broader background checks, and banning assault-type weapons and so-called bump stocks.

Walmart (NYSE: WMT) has announced that it would follow suit and stop selling guns and ammunition to anyone under 21 years of age. Walmart is also planning to remove all toys and airsoft rifles that resemble assault-style weapons from its stores.