A gunman burst into a North Carolina nursing home Sunday and opened fire on terrified people in their rooms, killing seven elderly residents and a nurse caring for them.

Authorities said Robert Stewart also wounded three others, including Carthage police officer Justin Garner, who traded gunfire with Stewart and wounded him in a hallway of Pinelake Health and Rehab. Stewart was subsequently arrested.

Garner, 25, was shot in the leg.

"He acted in nothing short of a heroic way today, and but for his actions, we certainly could have had a worse tragedy," said Moore County District Attorney Maureen Krueger. "We had an officer — a well-trained officer — who performed his job the way he was supposed to and prevented this from getting even worse than it is now."

Krueger said Stewart, 45, of Moore County, has been charged with eight counts of first-degree murder and a single charge of felony assault of a law enforcement officer.

Authorities offered few other details, except to say that Stewart was not a patient or an employee at the nursing home, and isn't believed to be related to any of the victims.

While authorities declined to comment on a possible motive, Stewart's ex-wife. Sue Griffin, said he had recently been calling family members, telling them he had cancer and was preparing to "go away."

"He did have some violent tendencies from time to time," Griffin said. "I wouldn't put it past him. I hate to say it, but it is true."

Shattered windows

Carthage police, Moore County sheriff's deputies and the State Bureau of Investigation conducted a search Sunday afternoon of the nursing home and its parking lot, where the windows of at least two cars were shattered.

Among the items they found was a camouflage-coloured rifle or shotgun, which was leaning against the side of a Jeep Cherokee.

"I don't know if the emotion entirely has set in," said Carthage police Chief Chris McKenzie. "It's a small community built on faith, and faith will get us through."

Carthage is a town of about 1,800 people in the North Carolina Sandhills, an area popular among retirees and home to several noted golf courses, including the famed Pinehurst resort that regularly hosts the U.S. Open.