After a decidedly challenging year, Target Corp. is finally building some momentum heading into the heart of the holiday season.

The Minneapolis-based retailer pleasantly surprised investors on Wednesday by posting a 1.2 percent increase in same-store sales in the third quarter, its biggest gain in that closely watched metric in more than a year.

Sales were lifted in part by back-to-school and Halloween spending as well as strong showings in its toy and beauty departments. By comparison, its bigger rival, Wal-Mart Stores Inc., reported a 0.5 percent gain for the same period.

Target said it expected to do even better during the fourth quarter, when it forecasts comparable sales to rise 2 percent. That would be its best showing in the last two years, though the comparison is against the period when sales plunged after a data breach last December scared away some Target shoppers.

In addition to the jump in same-store sales, Target beat expectations in the quarter ended Nov. 1 with profit that rose 3.1 percent and overall sales up 2.8 percent.

Investors reacted to the news by sending the company’s shares up 7.4 percent to $72.50, the highest close of the year. Shares briefly went above $73, near the all-time high of $73.41 set in June 2013.

“There were a lot of people who thought this ship was sinking and it was going to be way harder to turn it around,” said Brian Yarbrough, an analyst with Edward Jones. “But I think they’ve started to turn it.”

He added that the stores are looking better and Target has been rolling out more exciting merchandise, such as its holiday partnership with Toms, that is helping it reclaim its cheap-chic mantle.

“It feels like they’re getting back to what drove them in the ’90s and what has differentiated them from Wal-Mart and Amazon,” Yarbrough said.

Still, Target executives said they remain cautious about the next three months amid a promotional and competitive retail landscape. While there have been some encouraging signs such as lower gas prices, they noted that consumers spending remains volatile.

Brian Cornell, who joined Target as chief executive in August, has concentrated on helping it recover from the data breach, re-engineer its expansion into Canada and revamp its online offerings.

On Wednesday, Cornell outlined some of his strategic priorities, including doubling down in digital commerce, better catering stores to local tastes, focusing on smaller store formats such as CityTarget and TargetExpress, and trimming costs to help fuel new investments. And, as he told employees at an annual meeting in September, he wants to invest more resources in Target’s signature categories such as style, baby, kids, and wellness.

“This doesn’t mean we’re abandoning our other categories,” he said, adding that the retailer won’t step back from groceries, but may retool it to have more of a focus in natural and organic products.

Most of these ideas seem logical, David Strasser, an analyst with Janney Capital Markets, wrote in a research note. “Assuming execution follows, [Target] should be back on track,” he wrote.

But Canada continues to be a problem for Target. Its 133 stores there came in with lower-than-expected sales and racked up a $211 million loss in the quarter. That brings the Target Canada’s total loss to date to roughly $1.6 billion since it began expansion there last year. Some analysts have suggested that Target should begin closing some of those stores if results don’t quickly improve.

Cornell said Wednesday that he expects to see much better performance in the Canadian stores during the holidays when traffic will naturally pick up. He noted that the company has been working hard to fix pricing, assortment, and stocking of items. But so far, Target executives said, customers have not necessarily given Target credit for the changes.

“The guest response to these changes both in their shopping behavior and overall sentiment toward Target will inform our perspective as we continue to assess our longer term potential in Canada,” Cornell said.

On a brighter note, Target is seeing more signs that shoppers continue to move past last year’s data breach. After some steep drop-offs early in the year, the number of transactions in Target’s U.S. stores was just 0.4 percent lower than it was a year ago.

John Mulligan, Target’s chief financial officer, told reporters that he was especially pleased by Target’s sales and traffic in the quarter since it had pulled back on some of the heavy promotions it offered earlier in the year to drive back shoppers into the stores after the breach.

Online sales continue to show a lot of growth, rising 30 percent in the quarter. Executives said they expect that pace to accelerate to 40 percent during the holidays, boosted in part by Target’s aggressive promotion it launched in late October to offer free shipping on any size order through the holidays.

It’s a good sign that Target is finally beginning to show progress with its U.S. stores, turning the focus away from the data breach and its Canadian struggles that have overshadowed the retailer in the last year, said Jason Long, a retail consultant with St. Louis-based Shift Marketing Group.

“They are getting their mojo back,” he said. “It’s a big deal going into the holidays, and great news for Cornell.”