NEW YORK -- Walmart beat expectations on quarterly profit and revenue, and e-commerce sales surged during the critical holiday period.

Shares moved sharply higher before the opening bell Tuesday.

Walmart is the first major retailer to deliver fourth-quarter results and its performance provides more evidence that efforts to expand services online as well as in the stores are widening the gap between itself and traditional rivals while at the same time, it's holding its own against Amazon.

The huge numbers from the world's largest retailer are especially encouraging after a very weak December retail sales report last week from the U.S. Commerce Department led many to fear that consumers had gone into hiding.

The government data, delayed by a government shutdown, hinted that a volatile stock market, a government impasse, and a trade war with China had taken their toll on the American psyche.

That, at least in Walmart's case, appears to be untrue. Walmart and other retailers are also benefiting from the woes of others. Toys R Us and Bon-Ton Stores have gone out of business, and the list of casualties keeps getting longer. This week, Payless ShoeSource began liquidation sales at more than 2,100 stores in the U.S. and the Puerto Rico. Sears is shrinking and J.C. Penney is floundering.

Walmart posted strong sales across a wide range of products from toys to groceries and electronics. That helped sales at stores open at least a year rise 4.2 per cent at its U.S. namesake stores, following a 3.4 per cent pace in the fiscal third quarter.

Since buying Jet.com more than two years ago, Walmart has been expanding online by acquiring brands and adding thousands of items.

It's also been ramping up grocery delivery and pickup options. Walmart now offers grocery delivery service at 800 stores and grocery pickup at 2,100 stores

Walmart has revamped its website with a focus on fashion and home furnishings. That all helped to drive a 43 per cent increase in e-commerce sales in the quarter, matching the pace from the previous period.

Walmart has become a gravitational force online surprisingly fast.

"Pleasingly, Walmart is successfully broadening its online base of customers and is now attracting both younger and more affluent demographics," wrote Neil Saunders, managing director of GlobalData Retail, a retail research firm. "These are early days, but Walmart is now a serious contender in the online space and presents a much more serious threat to Amazon than it did 18 months ago."

The company had a fourth-quarter profit of $3.69 billion, or $1.27 per share. Earnings, removing one-time items, were $1.41 per share, which is 8 cents better than analysts had expected, according to a survey by Zacks Investment Research.

The Bentonville, Arkansas, company had revenue of $138.79 billion, also better than expected.

Shares of Walmart Inc. rose 4 per cent, to $103.70 in premarket trading.