Wal-Mart Stores Inc.’s share price climbed almost 9 percent Thursday after the company reported surprisingly solid traffic and a sunny outlook for this year. Meanwhile, rival Target Corp. slumped a day after disappointing Wall Street with diminished projections and flattening traffic.

Wal-Mart’s expectations show a company rebounding from a less-than-stellar 18 months. In contrast, Target appears to be headed in the other direction, posting its lowest growth since 2014 and projecting flat or declining sales for the coming year.

Why the difference? In the first quarter, the two retailers posted some similar figures on the pillars of their business. Same-store sales were up 1 percent at Wal-Mart, compared with 1.2 percent at Target. Apparel and other merchandise delivered percentage gains in the low single digits at both stores, bucking the trend of plummeting clothing sales at department stores such as Macy’s.

But it’s on the margins where the two diverged.

Wal-Mart’s pharmacy sales grew faster than any of its other segments, posting mid-single-digit gains because of increases in prescriptions and branded drug prices. Target missed the boat on both those trends, having sold its pharmacy unit to CVS in December.

Wal-Mart also came out more bullish on its digital strategy, reporting quarterly growth in online commerce of 7 percent, bolstered by the rollout of the company’s new grocery delivery service. Even that number, which equates to 31 percent annual growth, was “too slow,” Wal-Mart CEO and President Doug McMillon said.

At Target, online sales showed signs of cooling. In the first three months of 2016, digital sales grew 23 percent, a deceleration from the torrid 38 percent clip the company reported in the same quarter last year.

More broadly, though, the two companies have staked out different strategies for the years ahead. Target is midway through a $2 billion round of cost-cutting, led by thousands of layoffs last year. Wal-Mart has also continued on its eternal quest to stay lean, but the company has invested heavily in inventory management and staff training, pointing toward future payoffs in cash flow and profitability.

For the time being, however, Wal-Mart’s profits have fallen due to expenses, which include inventory adjustments and wage increases announced last year. Selling, general and administrative expenses — basically, the cost of operations and wages — rose at Wal-Mart. At Target, this line item fell 0.5 percent.

Walmart Store, Secaucus, New Jersey, Nov. 11, 2015 A shopper inspects the fresh produce at a Walmart store in Secaucus, New Jersey, Nov. 11, 2015. Photo: Reuters/Lucas Jackson

But the bottom line comes down to customers. Retail demand tapered in the first two months of the year as financial markets wobbled and recession fears crept into focus. Since then, however, retail spending has climbed back up. “Compared to a year ago, things are looking pretty good,” said Chris Christopher, IHS Economics director of U.S. and global consumer economics.

But Target hasn’t been able to shake the pain from earlier in the year. “It’s clear that consumers are behaving more cautiously,” Target Chief Financial Officer Cathy Smith told investors Tuesday.

Wal-Mart’s rosier projections reflect a different reality, driven in part by its offerings and the lower-income profile of its customer base. About one-half of Wal-Mart’s sales come from grocery purchases, compared with about 20 percent at Target, bringing customers into its stores even when merchandise shopping isn’t on their minds.

“The pullback is probably more severe in the upper-income markets,” Christopher said. “People who live paycheck to paycheck really can’t pull back.”