BENTONVILLE, Ark. — In its latest effort to compete with the online giant Amazon, Walmart is testing a delivery service using its own store employees, who will deliver packages ordered online while driving home from their regular work shifts.

The ‘‘associate delivery’’ program would use Walmart’s 4,700 US stores and roughly 1.2 million employees to speed deliveries and cut costs, the company said Thursday, a day before the company’s annual meeting.

The world’s largest retailer says workers can choose to participate and would be paid. The service is being tested at two stores in New Jersey and one in Arkansas.

Walmart has stores within 10 miles of 90 percent of the US population, the company says.

‘‘Now imagine all the routes our associates drive to and from work and the houses they pass along the way,’’ Marc Lore, chief executive of Walmart’s US online operations, wrote on the company’s website.

Ravi Jariwala, a spokesman, said all those employees driving home represent a ‘‘very dense web’’ of potential delivery locations.

Employees who participate can use an app to specify how many packages they are willing to deliver, Jariwala said, as well as weight and size limits of the packages. Jariwala would not provide details about how workers would be paid, but said the company would comply with all minimum wage and overtime laws.

‘‘This is completely an opt-in program,’’ he said Thursday. ‘‘This is not something they are required to do.’’

So far, employees ‘‘love having the option to earn more cash while doing something that’s already part of their daily routine,’’ Lore wrote.

Some critics of Walmart’s labor practices questioned how voluntary such a program would be.

‘‘When so many workers are paid so little that they need government assistance to make ends meet, it becomes a necessity, not a choice, to do what they can to earn more,’’ said Randy Parraz, director of Making Change at Walmart, a group funded by the United Food and Commercial Workers union.

The move could result in significant cost savings. The company didn’t provide estimates. Still, the final delivery step to a customer’s home — what the industry refers to as the ‘‘last mile’’ — ‘‘makes up the lion’s share of fulfillment costs,’’ Jariwala said.

Shoppers on Walmart.com can already choose to pick up items at a nearby store for a lower price. Walmart has also revamped its shipping program and offers free, two-day shipping for online orders of its most popular items, with a minimum purchase of $35.

In tests so far, Walmart says, ‘‘many’’ packages are arriving at customers’ homes just a day after an order has been placed.

Employee drivers will have to undergo background checks, including of driving records.

Faster shipping has become a key area of competition as online retail continues to grow at a double-digit pace, while traditional brick-and-mortar stores struggle with falling sales.

Members of Amazon’s $99-a-year Prime service in thousands of areas can receive orders the same day or the next, depending on the item and location. And in about 30 cities, including Boston, Prime Now members can get some items in an hour or two.

Walmart has previously tested delivery services using Uber drivers. Jariwala said that test is still going on. But Lore noted that third-party services require a driver to travel to a store to pick up a product.