Stanley Black & Decker is buying the Craftsman tools brand from Sears in a deal valued at $900 million. (Mike Mergen/ Bloomberg News)

Sears on Thursday announced that it has agreed to sell its Craftsman tools brand to Stanley Black & Decker in a deal valued at $900 million, the latest bid by the flailing retail chain to try to drum up cash to reposition itself for an era when e-commerce is gobbling up more of consumers’ shopping dollars and department stores have lost their luster.

The retailer also said it would close 150 stores by the end of March, including 41 Sears outposts and 109 Kmart locations. A Kmart store in Fredericksburg, as well as one in Baltimore, are among those that are on the chopping block.

Sears’s poor holiday season sales illustrate the depth of the company’s problems. Sales at Sears and Kmart stores open more than a year declined 12 to 13 percent. That performance comes in a holiday shopping season in which the retail industry is generally expected to have fared well, with a forecast from the National Retail Federation predicting 3.6 percent sales growth.

Sears is not alone among its traditional retailing peers in delivering weak sales during this crucial period. Macy’s said this week that its comparable sales dipped 2.7 percent in November and December, while Kohl’s reported a decline of 2.1 percent on that measure.

The Craftsman sale will give Sears an infusion of cash as it aims to repair its troubles. The deal gives Black & Decker the rights to manufacture and sell Craftsman gear in retail locations outside Sears. Sears will continue selling Craftsman gear, but for the first 15 years, it will not have to pay royalties to do so.

Black & Decker has big plans to grow the Craftsman brand, which currently sells only 10 percent of its products outside the Sears portfolio.

“This agreement represents a significant opportunity to grow the market by increasing the availability of Craftsman products to consumers in previously underpenetrated channels,” James M. Loree, Stanley Black & Decker’s chief executive, said in a statement. “We intend to invest in the brand and rapidly increase sales through these new channels, including retail, industrial, mobile and online.”

Black & Decker also pledged that it would expand its manufacturing operations in the United States to support its plans for Craftsman, adding that it has already grown its American manufacturing workforce by 40 percent in the past three years.

Sears also said Thursday that it has secured a $500 million real-estate-backed loan.

“We are committed to improving short-term operating performance in order to achieve our long-term transformation,” said Edward S. Lampert, chief executive of Sears Holdings.