NEW YORK – Walmart (WMT) is reporting better-than-expected profit and revenue for the first quarter with rebounding e-commerce sales.

Revenue at Walmart stores opened at least a year rose 2.1 percent, the company said Thursday, also surprising Wall Street.

It's an encouraging report from Walmart, which like other retailers is looking at new ways to compete in light of swiftly changing shopping habits and intense competition from Amazon (AMZN).

Get Breaking News Delivered to Your Inbox

Walmart, while spending more on its workers to improve service, is building fewer big stores, and its focus is solidly online.

Since buying Jet.com for more than $3 billion nearly two years ago, Walmart has buttressed its presence online, acquired brands like Bonobos and ModCloth, and vastly expanded the number of goods its sells from its site.

It's also strengthening delivery to make shopping at Walmart even easier. In March, Walmart began expanding its same-day delivery service to more than 40 percent of U.S. households, or 100 metro areas by year-end.

Walmart is reworking its website with a focus on fashion and home furnishings. It has teamed up with Lord & Taylor to create dedicated space on its site, which will be launched in the next few weeks.

Online sales rose 33 percent in the first quarter, a strong showing following a disappointing 23 percent increase in the final quarter of last year. Wall Street punished the company for the end-of-year e-commerce performance, sending shares plunging more than 10 percent. It was the biggest single-day percentage drop in 30 years.

Still, digital sales are below the 40 percent growth that Walmart is expecting for this year.

Walmart has a long way to get even close to Amazon's online dominance. Amazon has leveraged its Prime membership program into intense loyalty from customers. Amazon recently raised its annual fee for membership to $119, from $99. And it's stepped into Walmart's turf, no longer content with only online sales.

After spending $14 billion to acquire Whole Foods last summer, Amazon announced two-hour delivery from the grocery chain for its members. It also said that Prime members will get an additional 10 percent on sale items and exclusive deals on certain groceries at Whole Food stores. Those expanded benefits go nationwide this summer.

While it fights off rivals at home, the world's largest retailer is expanding elsewhere, with new moves into India and China.

This month, it acquired a controlling stake in Flipkart, India's largest online retailer. The $16 billion deal is Walmart's biggest acquisition yet. It's selling its British unit, Asda, which has been struggling with intense competition from German no-frills discounters Aldi and Lidl.

Walmart posted a first-quarter profit of $2.13 billion on Thursday, or 72 cents per share. Earnings, adjusted for nonrecurring costs, were $1.14 per share, which is 2 cents better than industry analysts were expecting, according to a survey by Zacks Investment Research.

That compares with $3.04 billion, or $1 per share, in the year ago quarter

The Bentonville, Arkansas, company's revenue rose 4.4 percent to $122.69 billion, beating projections for $120.08 billion.

Shares of Walmart rose around 1.6 percent before Thursday's opening bell on Wall Street.