Aberdeen police say it all began when they responded to a theft call at the store in the 200 block of Turner Street.
While they were there, police observed 22-year-old Christian York, who had been banned from the store earlier.
Police confronted York, who fled. They chased him on foot, and he was apprehended.
During the chase, police say the suspect dropped a handgun in the store. Another suspect, who later was determined to be York's brother, 18-year-old Justin York, picked up the weapon.
The Walmart was evacuated as a precaution. Police searched the premises and viewed surveillance footage and determined that Justin York had left the store.
The Walmart reopened about 30 minutes after the incident began.
Both Christian and Justin York have been arrested.