Marcell Willis also fired once at a third employee but missed before he shot himself with a handgun, authorities said.
Willis died at a hospital. He was stationed at Grand Forks Air Force Base, where 3,000 Air Force personnel and civilians work, according to the facility's website.
Andy Legg, who was shopping in the store, told CNN affiliate WDAY
he heard three or four gunshots just after 1 a.m., and people started running and screaming.
"Just replaying it in my head it's still kind of hard to grasp," Legg said.
Police said they would release the names of the victims on Wednesday.
"We are deeply saddened about this situation and our thoughts and prayers are with the victims and their families," Walmart spokesman Brian Nick said. "We are still learning information about the events surrounding this tragedy and assisting law enforcement in their investigation."
There is no obvious link between Willis and the victims or to the store, police said. Officers have spoken to some witnesses, but were encouraging others to get in touch with them.
The Air Force Office of Special Investigations is working with police on the case, the military said.
Mayor Michael Brown said the deadly incident is a shock to the residents of the town of 55,000 people.
"I can't remember anything this tragic in our community and that's why I think it's so shocking to happen like this," he said.
Eddy Eley of Grand Forks agreed.
"This happens in cities, big cities, not here and to know a couple people are gone because of it is devastating, Eley told CNN affiliate WDAZ
. "I don't want to ever see that happen here again."