Dick’s Sporting Goods Inc. DKS 2.01% is paying a price for its decision earlier this year to stop selling guns to people under 21 as sales continued to sag in its latest quarter.

Sales at existing stores and websites fell 3.9% for the three-month period ended Nov. 3., driven down by weakness in the company’s hunting and electronics departments, executives said on a conference call with analysts on Wednesday. Those categories accounted for over half of the decline. Weak gun sales also hit other areas like outdoor equipment because fewer hunters are coming to stores, said Lee Belitsky, chief financial officer at Dick’s. It was the chain’s fifth consecutive quarter of sales declines.

In February, Dick’s said it would stop selling assault-style guns and would no longer sell guns and ammunition to people under 21 years old in the wake of a shooting at a Florida high school that killed 17 people. At the time, Walmart Inc. also stopped selling guns and ammunition to those under 21, but the retail giant hasn’t said the decision created a slowdown in sales.

Dick’s sagging gun sales come as gun purchases overall have slowed during the Trump presidency. Gun sales tend to surge under Democratic leadership, as buyers anticipate strong gun-control laws.

”In addition to the strategic decisions we made regarding firearms earlier this year, the broader industry has decelerated and remains weak as evidenced by most recent national background check data,” said Mr. Belitsky on the call.

Dick’s is shrinking the space allocated to hunting gear and guns in some stores in favor of faster-growing, higher-margin categories like baseball gear, higher-end kayaks and licensed team sports gear, as well as experiences for customers including batting cages, said Dick’s Chief Executive Ed Stack on the call. “We think the vast majority of these headwinds will diminish and we’ll be in a better position” to boost sales, said Mr. Stack.

For the full 2018 fiscal year, Dick’s raised its expectation for per-share earnings to $3.15 to $3.25, up from a previous view of $3.02 to $3.20. The company said it still expects same-store sales to fall 3% to 4% for the full year.

On Wednesday Dick’s reported earnings of $37.8 million, or 39 cents a share for the quarter, compared with $37 million, or 35 cents a share, in the comparable period last year. Analysts polled by FactSet forecast 27 cents a share.

Write to Sarah Nassauer at sarah.nassauer@wsj.com and Micah Maidenberg at micah.maidenberg@wsj.com