Updated

A dispute between neighbors ended with both men dead but the safe emergence of two children and the shooter's wife from an all-day standoff at a suburban San Diego apartment, authorities said.

The gunman, a 42-year-old man identified only as Michael, fatally shot his neighbor Thursday morning and killed himself several hours later, Chula Vista police Capt. Lon Turner said.

In the hours between the deaths, the man, his wife and two small boys, whose relationship to the adults was not revealed, were holed up inside an apartment while police tried to draw them out.

The woman and children left unharmed by 4 p.m. and were driven away by a police car.

"We all breathed a collective sigh of relief" when they came out, Turner said.

It wasn't immediately clear whether the wife and boys were being held against their will or voluntarily staying inside.

About an hour later, alone inside the apartment, the man killed himself, Turner said. A SWAT team sent in surveillance robots, then went in to find the man dead, Turner said.

The woman, identified only as Laura, and the boys, who are both under 9 years old, walked out after police negotiated by cellphone with the man, who had begun talking about surrendering, Turner said.

The couple had been married for about a year. The woman told police that her husband had more weapons and ammunition inside the apartment, which police planned to search.

The standoff began when the man killed a neighbor and retreated into the apartment, police said. The victim's body remained between cars outside the complex for hours because it was in the line of fire and too dangerous to retrieve, Turner said.

Authorities helped 56 people, including the victim's family members, evacuate from the 39-unit complex of low-slung, lime-green apartments.

Humberto Carranza's wife, 8-year-old son and 2-year-old daughter were among the evacuees. Carranza, who was at work as a door installer when he heard about the standoff, spoke with his wife by phone throughout the ordeal as SWAT officers stood in their backyard with sniper rifles.

Carranza, 33, said he knew the man involved in the standoff, and their boys are classmates who play together.

"I don't know what went wrong," he said. "He seemed to be all right. I just saw him yesterday and he said hi."