The 20-year-old man who sparked an active-shooter panic at a Missouri Walmart when he walked into the store in a ballistic vest and carrying an AR-style rifle told police he wanted to see whether the retailer "honored the 2nd Amendment," police said in court documents.

Dmitriy Andreychenko has been charged with making a terrorist threat in the second degree at the Walmart Neighborhood Market in Springfield on Thursday, Greene County Prosecuting Attorney Dan Patterson said in a statement Friday.

Missouri is an open-carry state, meaning state law does not prohibit gun owners from openly carrying firearms.

"That right does not allow an individual to act in a reckless and criminal manner endangering other citizens," Patterson said.

Dmitriy N. Andreychenko is seen in this booking photo. Springfield Police Department / AFP - Getty Images

No shots were fired, and an armed man described as a former firefighter detained Andreychenko outside the store until police arrived, authorities said.

The incident occurred just days after a gunman walked into a Walmart in El Paso, Texas, and opened fire with what police said was an AK-47-style rifle, killing 22 people in an attack that allegedly targeted people of Mexican descent.

Early the next day, a gunman was killed by police after he fatally shot nine people in Dayton, Ohio.

Andreychenko walked into the Springfield Walmart store with the AR-style rifle slung across his chest and a handgun on his hip and was filming himself with a cell phone, according to court documents. He told police he was recording video in case someone tried to stop him, the documents said.

His appearance sparked a panic, prompting the store manager to pull the fire alarm because he thought Andreychenko would shoot people. Witnesses and police described shoppers fleeing the Walmart and hiding behind barriers outside.

Andreychenko told police he was there to buy grocery bags and did not intend for people to react the way they did, according to a police probable cause statement.

"This is Missouri, I understand if we were somewhere else like New York or California, people would freak out," he told police, according to the police statement. He also allegedly said he bought the rifle and body armor to protect himself after recent mass shootings.

Online court records did not list an attorney for Andreychenko. He was being held in lieu of $10,000 bail, the jail said.

His wife and sister both told him that his plan to walk into the store with a gun was not a smart idea because of the recent mass shootings, the police probable cause statement said.

Andreychenko left the store through an emergency exit and was detained at gunpoint by a man who authorities described as a former firefighter.

The former firefighter told NBC affiliate KYTV of Springfield that he approached Andreychenko outside and asked if he was the man with the rifle. When Andreychenko replied he was, the former firefighter pulled his gun and ordered Andreychenko to put his hands in the air.

The former firefighter, also described as a former military member, told the TV station he was glad Andreychenko was charged.

"I'm very pro-Second Amendment," he told station. "But if his intention was to come in and cause that kind of a panic and try to make people run in fear or whatever the case may be, then that's what he deserves."

Patterson said the charge of making a terrorist threat pertains to someone who recklessly disregards the risk of causing an evacuation and communicates a threat or knowingly causes a false belief or fear that an incident has occurred.

He said the felony is punishable by up to four years in prison and a fine of up to $10,000.

Patterson said a police officer from the nearby town of Battlefield and another person were hurt in a vehicle accident while police responded to the Walmart.

Walmart said Friday that the incident "was a reckless act designed to scare people, disrupt our business and put our associates and customers at risk," and that he is no longer welcome at Walmart stores.