Macy’s Herald Square store in New York. (Chris Hondros/Getty Images)

Department store giant Macy’s said Thursday it plans to close 100 stores, a dramatic step that is aimed at helping the chain get ahead of a potentially crippling problem: America, executives say, has too many stores for the online shopping era.

Macy’s has been steadily pruning its portfolio, often moving to close several dozen underperforming stores right after the annual holiday rush. But in dropping a summertime announcement that it will close 15 percent of its locations, the chain appears to be moving more aggressively than many of its retail industry counterparts to adapt to a fast-changing shopping environment.

Macy’s has plenty of reasons to scramble: Many of its stores are located in small, regional malls, the kind whose foot traffic has been especially hard-hit by the rise of e-commerce. And the department store category has generally struggled as shoppers increasingly turn to off-price retailers such as T.J. Maxx and fast-fashion players such as H&M to buy their clothes.

These factors, along with a pullback in spending by international tourists and unseasonable weather, have left Macy’s in a rut that has stretched for more than a year. On Thursday, the company said it saw a 2.6 percent drop in comparable sales in the most recent quarter, a weak performance that was nonetheless an improvement over the dismal 6.1 percent year-over-year decline it recorded in the previous quarter. The retailer’s revenue was $5.87 billion, down 3.9 percent from the same period last year.

Macy’s said the store closures would probably cost it about $1 billion in annual sales. And at one time, such a large batch of store closures might have been viewed as a retailer’s concession of defeat. But in this instance, the company’s stock soared 17 percent on Thursday, a sign that investors view the move as a proactive measure portending a stronger future for Macy’s.

In some ways, it should not come as a surprise that Macy’s is slashing stores. It has some 675 full-line stores, or 728 if you include outlets such as Macy’s Home stores. Terry Lundgren, the retailer’s longtime chief executive, has been saying for a while now that the chain simply had too many stores.

Jeff Gennette, the Macy’s executive who has been appointed to replace Lundgren in 2017, said in a statement that nearly all of the stores the company plans to close are ones at which sales volume and profitability have been sliding.

“We recognize that these locations do not yield an adequate return on investment and often do not represent a customer shopping experience that reflects our aspirations for the Macy’s brand,” Gennette said in a statement.

Macy’s said it is still finalizing which stores it would shutter, and thus has not yet determined exactly how many jobs will be slashed. The retailer said it does not plan to pull out entirely of any of the top markets where it currently operates stores, but it would look to close stores that are in weak locations.

The move is likely unwelcome news to mall operators, who count on big tenants like Macy’s to attract and retain other smaller stores in their shopping centers. If Macy’s leaves, the little guys could follow. Plus, the strategy raises questions about whether other department stores or big specialty retailers might be pondering similar moves.

Macy’s is among the first of a slew of mall and big-box retailers set to report earnings in the next week, and its results offered some encouraging signals about how the sector fared in recent months. Karen Hoguet, the retailer’s chief financial officer, told investors that hot summer weather helped give some momentum to clothing sales across its men’s, women’s and kids’ departments. She also said that Macy’s saw an improvement in sales trends at its major flagship stores, which draw a heavy share of their business from international tourists. Many retailers have said in the last year that sales have suffered as foreign visitors have pulled back spending here due to the strength of the dollar. It wasn’t all good news, though. Macy’s said transactions slipped 5 percent in the quarter, a measure that is something of a proxy for how much traffic there was in stores.

Macy’s also said Thursday that it is in negotiations to sell the 250,000 square feet of real estate that houses its men’s store on Union Square in San Francisco. It signaled that more such deals could be coming, saying that is “examining opportunities” for the real estate of four of its large flagship stores in major cities. Investors have long been urging Macy’s to re-evaluate its real estate portfolio, and Macy’s had earlier appointed an executive to focus on these efforts. The actions announced Thursday likely cheered investors who had been looking for Macy’s to unlock some cash from its lucrative real estate holdings.