Target's stock had the best day in its history on Wednesday, rising more than 20% after the mass retailer posted higher-than-expected sales and profits that erased lingering doubts about the strength of its business.

"In the past, there were some holes you could point to in the Target story," said Brian Yarbrough, an analyst with Edward Jones. "But today, there's really no holes. They've executed. They're proving that stores are still important."

Target's margins have been "squishy" in the past, squeezed by price cuts to compete with Walmart and Amazon and the higher costs to fulfill online orders, Yarbrough said. But on Wednesday, Target posted its first quarterly increase in gross margin rate in nearly three years and raised its overall profit outlook for the year.

Target also showed that consumers are still interested in coming to its stores and are flocking to its same-day services of in-store pickup, curbside pickup and home delivery via Shipt, which have doubled in sales volume in the last year.

The solid metrics provided more proof points to Wall Street, allaying the fear that Target is going to be "another victim of Amazon," Yarbrough added.

Target's shares closed at $103. It was the first time shares were over $100 since the early 1980s when the company name was Dayton Hudson Corp. The stock has split three times since then.

It was the latest signal that investors, who were initially skeptical, have bought into the stores-focused turnaround plan of CEO Brian Cornell, who marked five years in the job this month.

Cornell has guided the company on a multiyear path to reinvigorate its business through remodeling hundreds of stores and launching dozens of new private-label brands across apparel, home decor, cleaning supplies and electronics, while retiring older ones. The company also has been opening about 30 small-format stores a year near college campuses and in urban areas and has rolled out curbside pickup and same-day delivery across the country.

The stock surge came after Target announced a 17% gain in profit for its fiscal second quarter and a 3.4% jump in comparable sales. The company was up against a tough comparison in the same period a year ago, when sales jumped 6.5% from a big windfall in toy sales after the bankrupt Toys 'R' Us shuttered all of its U.S. stores.

Growth in toy sales moderated for Target in this most recent quarter, but other bright spots such as apparel and household essentials, which increased more than 5%, emerged and helped drive robust sales.

While there have been concerns in recent weeks that the economy may be slowing down, Cornell told reporters that the retailer hasn't seen evidence of that.

"From a Target standpoint, we continue to see a very stable and healthy consumer environment," he said, nodding to lower fuel prices, low unemployment and growing wages. "And I think we're well positioned to take advantage of that."

With some retailers struggling, particularly department stores such as Macy's and J.C. Penney, Cornell said the gap between winners and losers has been widening. Those that are winning, like Target, have invested in their businesses to adapt to changing needs of consumers and are picking up market share from those that are losing, he said.

"Obviously, we feel very good about our exceptional performance in the second quarter," he told reporters. "But we are not alone. There are others that are certainly on the winners' circle right now standing alongside us. And there are unfortunately others that have been closing stores and trying to cut expenses. They are the share donors that certainly are helping our performance."

Neil Saunders, managing director of GlobalData Retail, said Target's holistic approach to investing in stores, products, and services have earned it a place on the podium of retail winners this year.

"With both Target and Walmart producing good sets of numbers, the Middle American consumer is clearly alive and well," he wrote to clients. "However, they are favoring those retailers that have worked hard to deliver a compelling and engaging experience."

Charlie O'Shea with Moody's said the quarter couldn't have gone better for Target.

"Going forward, we expect Target to continue to be one of the top performers in U.S. retail," he said in a statement.

Target's improved profitability in the quarter was helped by the increase in apparel sales, which has higher margins compared with toys. The growth of same-day delivery services, which accounted for three-quarters of Target's 34% increase in digital sales, also has been helping Target defray costs. Those services help Target save money, compared with boxing up and shipping items to peoples' homes, because consumers either come to the stores to pick up the items themselves in the case of in-store and curbside pickup, or they pay a fee for delivery to their homes through Shipt, the delivery service Target bought in 2017.

John Mulligan, Target's chief operating officer, told analysts that same-day pickup and delivery options are becoming consumers' "go-to choice" for online shopping because they are immediate, convenient, fast and reliable.

"And it eliminates the need to deal with opening and recycling a stack of cardboard boxes every week," he added.

In the three months ended Aug. 3, Target's profit was $938 million, or $1.82 per share, an all-time high for the company and much higher than the $1.62 analysts had forecast. Revenue rose 3.6% to $18.4 billion.

The retailer's increased profit forecast for the year factored in upcoming tariffs. Cornell told analysts on Wednesday that most of the proposed tariffs that will affect Target, which have been delayed until mid-December, won't be felt until next year.

Target said it expects sales in the second half of the year, including during the important holiday season, to be in line with the 3.4% increase it posted in the second quarter.

Earlier this week, Target unveiled its newest brand, a flagship grocery line called Good & Gather, which will begin rolling out to stores next month and which will replace store brands Archer Farms and Simply Balanced as well parts of the Market Pantry line. The move is aimed at helping differentiate Target's grocery offerings, which haven't been a historic strength for the retailer.

It also recently expanded a test of selling Levi's "Red Tab" label jeans to 50 stores and on The jeans maker has been looking for other places to sell its denim as Sears has shuttered stores and its sales have declined.

Target did have one noticeable hiccup in the quarter. Cash registers went down and credit card glitches prevented sales for several hours over Father's Day weekend, but Cornell said that did not have a significant effect on sales and profits.