A 22-year-old bystander who witnessed a deadly shooting over the weekend at a shopping mall near Indianapolis was hailed as a hero on Monday for killing the gunman and limiting the number of casualties in the massacre.

Local officials said the "Good Samaritan" - a man who was lawfully carrying a firearm - stopped the gunman almost as soon the suspect opened fire on Sunday in the food court of the Greenwood Park Mall in Greenwood, Indiana, outside of Indianapolis.

In addition to the gunman, who had a rifle and several magazines of ammunition, three people were killed and two others were wounded.

"We do know that someone we are calling a 'Good Samaritan' was able to shoot the assailant and stop further bloodshed. This person saved lives tonight," Greenwood Mayor Mark Myers said in a statement. "I am grateful for his quick action and heroism."

The motive behind the shooting is not known yet, Greenwood Police Chief Jim Ison said on Sunday, without releasing the names of the victims, gunman or bystander. There were four female victims and one male victim. One of the victims was a 12-year-old girl.

"Lives were lost today, and I'm thinking about all the victims of this horrible incident, now and in the days and weeks to come," Holcomb tweeted.

Federal and local authorities searched the apartment of the suspected gunman early on Monday, a Fox News affiliate in Indianapolis.

A spate of gun violence in public places since May, including mass shootings at a New York grocery store, a Texas elementary school and an Illinois Independence Day parade, has renewed fierce U.S. debate over gun regulations.

Gun rights advocates will likely seize on the killing of the suspect in Indiana as an example of why it is important to allow Americans to carry firearms.

"We will say it again: The only way to stop a bad guy with a gun is a good guy with a gun," the National Rifle Association said in a Tweet on Monday morning.

It is rare for a bystander to stop a mass shooting in the United States, according to an analysis by the New York Times. The newspaper showed that only 22 gunmen in the 433 shooting attacks since 2000 were shot by a bystander.

The incident also raises questions regarding the interaction between state law and the rights of companies and businesses to ban weapons on their properties.

The shooting comes just weeks after the Indiana Governor Eric Holcomb signed a bill into law repealed the state's handgun permit requirement. Now, anyone 18 years of age or older who is not legally prohibited from firearm possession may generally carry a concealed handgun in public.

The law conflicts with the policy of Simon Property Group, the owner of the Greenwood Park Mall, which prohibits guns on its properties, according to its website. The Indianapolis-based company was unavailable for comment on Monday.

According to Indiana Attorney General Todd Rokita, private businesses and property owners may restrict gun owners from carrying a weapon on their property.

Even so, it is generally not against the law to ignore a 'no firearms' sign at a private business, he wrote in the state's Gun Owners' Bill of Rights before the weekend shooting.

Rokita said the only consequence from ignoring a company's ban may come only after a direct warning to someone carrying a firearm on the property: "You may commit criminal trespass for entering a business after you have been denied entry or have been asked to leave," the bill of rights reads.