Bloomberg News

Costco Wholesale Corp. (COST) shares surged to the top of the S&P 500 Friday after the big box retailer smashed Wall Street's earnings estimates as food price inflation ease and domestic gas prices tumbled.

Costco not only topped Street forecasts with earnings for the three months ending on February 17 came of $2.01 per share -- some 22 cents ahead of the consensus, but also saw same stores sales, excluding fuel and foreign exchange moves, rising 6.7%. Comparable sales in the US jumped 7.2%, Costco said, again topping the 6.7% estimate, while core merchandise margins improved by 8 basis points after several quarters of declines.

"You know we drive our business by driving sales and usually that means lowering prices on things which we continue to do, and we're also buying better all the time," Costco CFO Richard Galanti told investors on a conference call late Thursday. "I appreciate the fact that every basis points for us is $14 million plus pre-tax a year of nearly 1 billion but you are talking about 5 to 10 basis point swings here and there's a lot of things that impact it, whether it's freight, tariffs, some -- negative, in some cases not as bad as we thought."

Costco shares were marked 4.94% higher in the opening minutes of trading, and the top of the S&P 500, to change hands at $227.54 each, a move that would trim the stock's six-month decline to around 6.4% and mark the biggest single-day gain in nearly two years.

Costco did, however, did fall short on total revenues, which rose rose 7.3% to $35.4 billion but missed analysts' estimates of $35.65 billion. But it also reported February sales of $10.72 billion, up 5% from last year, or 4.6% on a like-for-like basis, the company said.

Earlier this week, smaller rival BJ's Wholesale Club (BJ - Get Report) posted stronger-than-expected fourth quarter earnings if 44 cents per share, a 22.2% increase from the same period last year, even as sales slipped 3.9% to $3.42 billion.

Costco's E-commerce sales were up 20.2%, as well, thanks in part to the company's move towards a broader selection of Apple Inc AAPL products such as MacBooks and iMacs. The group is also planning to build automated e-commerce facilities to replace tradition shipping divisions that should further lower delivery costs and improve margins.

BMO Capital Markets analyst Kelly Bania, who has an outperform rating on the stock with a price target of $258.00, said the move "supports an outlook for longer-term efficiencies and strengthens our already bullish thesis related to improving its digital relationship with its customers and advantage business  model".