Target received a belated holiday gift to tie a pretty bow on an ugly year.

The Minneapolis retailer surprised Wall Street on Tuesday with earnings that beat expectations from both analysts and the company's own leaders, proving shoppers still depended on Target for their everyday needs despite the company's plunging profits.

After months of disappointing returns and some miscalculations on what products to keep stocked, Target showed in its fourth-quarter results that it has turned a corner with better-managed inventory levels and small — but consistent — sales improvement.

"Our growth in '22 didn't come easily," said Target CEO Brian Cornell at the company's Tuesday investor event in New York City. "It wasn't nearly as profitable as we expected to be over time. In 2020 and 2021, our team put in the effort and the hustle to keep pace with the most turbulent business environment many of us have ever seen."

Target said it earned $876 million, or $1.89 cents a diluted share, from November through January, considerably better than the $1.40 analysts forecast. Its fourth-quarter revenue of $31.4 billion, a change of a little more than 1% from the year before, was also higher than expected ($30.7 billion). Target shares closed up more than 1% Tuesday.

And for the second time, Target surpassed the $100 billion in annual revenues milestone, with total revenue up $3 billion to $109 billion. Yet profits for the general merchandiser still plummeted 60% this past fiscal year compared with the year before, from $6.9 billion to around $2.8 billion.

Some of the explanation for such a dive is Target having to weather more discerning shoppers amid high inflation and steep costs.

Last year, the prices of consumer goods shot up and pushed people to stop splurging on home goods, electronics and other nice-to-have-but-not-necessary products Target normally excels at selling. Left flat-footed with bulky and unwanted merchandise, Target stumbled through several quarters as it tried to deplete a bloated inventory by canceling vendor orders and slashing prices.

The adjustments eventually paid off. Target is in a better inventory position to start off this fiscal year, with inventory at the end of January valued at about $13.5 billion, a 2.9% decrease from January 2022. Inventory in discretionary categories was about 13% lower than a year ago.

"That's one of the biggest keys to me because that has been such a massive drag on profitability in 2022," said Brian Yarbrough, an analyst with Edward Jones, about the lower inventory levels.

Target's same-store sales, or sales from stores open at least a year, were up a modest 0.7% this past quarter, which was still an improvement from the single-digit decline the company said it expected in the fall.

That's partly thanks to shoppers continuing to turn to Target for necessities, including groceries.

"That's the beauty of the Target model," Yarbrough said. "When it's slower economic times, it is not as beneficial as it is for, like, a Walmart. But you still have the beauty, the essentials and the food categories and beverage categories that can grow nicely and help offset some of the declines in those discretionary categories."

To appeal to value-oriented shoppers, Target plans to expand its Target-owned brands and add more items starting between $3 to $15, such as the cheaper ornaments, candles and throw pillows shoppers might have found on shelves in the past few months.

"These are all incredible values that when you see them on an endcap or see them on a site, you just stop and say, 'Wow, I've got to get that,'" said Christina Hennington, chief growth officer for Target.

Even after worries about COVID-19 subsided last year, Target has also continued to grow its contactless services like drive-up, pickup and delivery, which saw 7% more use in 2022 compared with 2021 when many of the COVID-19 mandates discouraging in-store shopping were still in place.

"What they're proving is that a lot of the services that they've added, the same-day service pickup, they are kind of sticky," said Edward Yruma, a senior research analyst for Piper Sandler. "The consumer likes it. It gives them a degree of convenience."

The company announced it would continue to make capital investments up to $5 billion for the year to update 175 stores, open 20 new stores, grow its "sortation center" network and expand its same-day services to allow customers nationwide to return unwanted items via drive-up.

But still, there are plenty of hurdles on the horizon.

The products that remain popular at Target are low-margin items like food. At the same time, Target, like many other businesses, has needed to manage higher costs ranging from higher merchandise and freight costs to more expensive labor, as it has increased its employee compensation and headcount to continue to grow. There is also economic uncertainty that has made consumers more hesitant to spend.

Looking into the future, Target is more conservative with its financial forecast. The company announced it expects comparable sales from February through April and for the full year to range from a low-single-digit decline to a low-single-digit increase.

Mega-retailer Walmart, which also reported better than predicted earnings last week, said it expected its comparable sales in the United States to rise between 2% and 2.5% this fiscal year.

"I just think everyone's crystal ball is really cloudy right now," Yruma said.