Walmart is expanding its grocery business both in stores and online by adding more organic produce. (Joe Raedle/Getty Images)

Competition is heating up among U.S. grocery chains, but Americans are increasingly buying their food at Walmart.

The retailer on Thursday said food sales had grown to their highest level in five years, as Walmart expands its grocery business both in stores and online by adding more organic produce. The company is also testing grocery delivery in New York, and has taken aggressive steps to compete with Amazon.com, which is the process of buying Whole Foods Market for $13.7 billion, as well as with European discounters like Aldi and Lidl, which are ramping up their presence in the United States.

“We’ve seen strong results from the rollout of online grocery, which is now in more than 900 U.S. locations,” Doug McMillon, president and chief executive of Walmart, said in a Thursday call with analysts. “We’re expanding this service in many of our markets around the world.”

Earlier this year, Walmart created its own “designer” cantaloupe that it says tastes as sweet in winter as it does in summer, and a company spokeswoman says its next goal is to develop a more flavorful tomato. The company has also expanded its lineup of exclusive snacks, including Oreo O’s cereal and Jelly Donut Oreos.

Food sales make up more half of Walmart’s revenue, accounting for nearly $200 billion worth of groceries each year, said Joseph Feldman, an analyst for Telsey Advisory Group in New York. (By comparison, the country’s second-largest grocery chain, Kroger, brought in $115.3 billion last year.)

“There’s been a real effort to improve fresh foods — produce, meats — and they’ve been very aggressive in keeping prices low,” Feldman said. “Big picture, we’re feeling pretty good about Walmart.”

In all, the company said e-commerce sales increased by 60 percent in the most recent quarter. Walmart.com is now the second-largest online retailer, behind Amazon.com, following its $3.3 billion acquisition of Jet.com last year. (Jeffrey P. Bezos, the founder and chief executive of Amazon, owns The Washington Post.)

Sales at stores open at least one year rose 1.8 percent from a year ago, marking the 12th quarter in a row of gains. Second-quarter revenue rose 2 percent to $123.4 billion, up from $120.9 billion a year ago. Earnings, meanwhile, fell 20 percent to 96 cents per share, from $1.21 per share a year ago.

Walmart — the country’s biggest employer — has been moving quickly to build its Internet presence. So far this year the company has bought a number of e-commerce businesses, including ModCloth, ShoeBuy, MooseJaw and Bonobos. It is also beefing up its website: Walmart.com now offers more than 67 million products, a 30 percent increase since the first quarter of this year, according to McMillon.

“Our strategy is to make every day easier for busy families,” he said in the call. “To accomplish this, we continue our transformation to become more of a digital enterprise that moves with speed and agility.”

He added that Walmart is also testing new delivery strategies by enlisting store employees to deliver online orders on their way home from work. It is also offering discounts to customers who pick up online orders in-store, and plans to have 100 automated pickup towers in stores across the country by year’s end.

“Having stores within 10 miles of approximately 90 percent of the U.S. population allows us to serve customers in ways that are most convenient for them,” he said in the call.

Earlier this week, McMillon criticized President Trump for not “unequivocally rejecting the appalling actions of white supremacists” in Charlottesville. But although he spoke out against the president, McMillon said he planned to remain on Trump’s economic advisory council. (The president later disbanded the group following the resignation of a number of business leaders.)

Read more:

The unlikely reason Americans are shopping at Target again

Walmart CEO criticizes Trump but is not stepping down from advisory council

Applebee’s is done trying to win over millennials

Sequined sneakers and ‘millennial pink’: 5 back-to-school trends to watch