OLD BRIDGE, N.J. -- An ex-Marine who had suffered from depression and once tweeted about killing "everyone I see" opened fire in camouflage gear at a supermarket, gunning down two co-workers before he killed himself, authorities said.

Terence Tyler, 23, left his night clerk shift at a Pathmark store in Old Bridge Township around 3:30 a.m., drove off and returned 20 minutes later to the closed store with a handgun and an assault rifle similar to an AK-47, Middlesex County Prosecutor Bruce Kaplan said. About 12 to 14 workers were still there, inputting new prices into the computer.

Tyler fired more than 16 rounds from his rifle -- shooting at an employee standing outside and firing as he entered the store, blowing out the front windows, authorities said. He shot at five other workers in an aisle, killing Christina LoBrutto, 18, and Bryan Breen, 24, Kaplan said.

"I do not believe that they were specifically targeted. I believe everybody in the store was a target," said Kaplan.

Tyler, who began working at the supermarket less than two weeks ago, drew his handgun and killed himself, the prosecutor said.

The motive was under investigation. But family members said Tyler had been discharged from the Marines two years ago after suffering from depression and had never gotten over his mother's death; the shooting happened around the five-year anniversary of her death, they said.

And on a Twitter account in 2009, with a photograph identified by family members as Tyler, a post talks about hating Marine life.

"I'm starting to see why plp go on killin sprees," he wrote in October 2009, using the handle @Tylerbkstyle. And these (obscenity) are reeeeeeally pushin my kill everyone I see button."

At the top of Tyler's Facebook page reads the motto, "Be optimistic. All the people you hate are going to eventually die."

Kaplan and police walked through the shooting scene at the supermarket Friday morning, with two long windows in the front completely shot through. Evidence markers were placed next to broken glass outside the store, in a suburban shopping centre about 40 miles (64.37 kilometres) south of Manhattan. Several ammunition magazines were recovered along with Tyler's rifle and a .45-calibre handgun, he said.

John Niccollai, president of a foodworkers union, said many of the employees working escaped the gunfire when an assistant manager got many of them to flee out the back door.

Breen and LoBrutto were both cashiers who normally worked day shifts, but pulled overnight shifts every few weeks to input new price changes, Niccollai said. Tyler had only worked for Pathmark since Aug. 20 as a night clerk stocking shelves.

Pathmark worker Miranda Miranda said she steered clear of Tyler. "The way he looked at me, he gave me an uneasy vibe," she said.

Miranda had regularly worked the overnight shift on Thursday but said LoBrutto agreed to take over the shift for her a few weeks ago. "That could've been me," she said of LoBrutto.

Tyler was discharged from the Marines in 2010 after just under two years in the service in Twentynine Palms, California, the Marines said. Tyler, from New York City, never served overseas, said Marine spokeswoman Capt. Kendra Motz. She wouldn't comment on the circumstances of his discharge.

His uncle, Christopher Dyson, said he left after suffering from depression, and a cousin said he had been hospitalized and was never happy with the Marines. Tyler, who also lived in San Diego, left California in June to move to New Jersey, where he lived with his sister and uncle.

"He was a quiet cat, you know?" Dyson said. "We don't know anything that would compel him to do this."

His cousin, Shanteya Dyson said Tyler had not been the same since his mother died of cancer. His father died when he was young.

"That was his best friend. He was always a quiet guy. But he got more quiet. He really didn't speak at all. He was just blank," said Dyson.

Tyler spent the July 4 weekend drinking at Jersey shore bars with Manase Acheantong, who said Tyler was his friend's cousin.

"We went out. We had drinks. He was a normal kid. He didn't start no fights. He didn't seem crazy," said Acheantong, 25.

Pathmark's parent company, Montvale-based Great Atlantic & Pacific Tea Co. said Friday the company is "deeply saddened" by the shooting and is co-operating with investigators.