A 66-year-old man with a history of confrontations at his Northwest Side condo building entered his next-door neighbors’ unit Saturday evening and shot to death four people inside as they ate dinner, then shot another neighbor one floor above who died Sunday, police said.

The shooting rampage began about 5:30 p.m. when the gunman went into his next-door neighbor’s unit on the second floor of the building in the 6700 block of West Irving Park Road in the Dunning neighborhood and fatally shot what police described as a family of three men and one woman eating supper.

“For reasons we yet don’t know, he opened fire on all four of those individuals, killing them all,” First Deputy Supt. Anthony Riccio said Saturday.

The Cook County medical examiner’s office identified one of the four victims killed Saturday as Tsvetanka Kostadinova. The identities of the other three also shot in that unit have not been released.

The gunman next went to the building’s third floor, where he confronted 53-year-old Jolanta Topolska, who lived there with her family, and shot her, authorities said. She was taken to a hospital in critical condition but succumbed to her injuries Sunday morning.

All of the victims appeared to be adults and knew the shooter, Riccio said.

An autopsy Sunday ruled their deaths to be homicides, the medical examiner’s office said. Kostadinova and another victim died of a gunshot wound to the chest and abdomen, respectively, while two others died of multiple gunshot wounds.

“It definitely wasn’t random. He lives in the building; he’s lived there for 15 years. He knows all the victims, but he’s not talking,” Riccio said.

The gunman surrendered himself to police without incident after the shooting. He was still being interrogated Sunday morning, according to police spokesman Anthony Guglielmi, who said the man’s identity would be released once charges are formally filed.

Riccio said the shooter was a retired construction worker whose neighbors described him as having “anger management issues.” He had a history of complaints from other residents, including playing loud music and “exchanging dirty looks.”

“We don’t know what set him off tonight,” Riccio said. “Most of the occupants inside the building have had problems with him in the past, but certainly nothing of this magnitude.”

One resident who asked not to be named recalled that the alleged gunman had gotten into a fight within the last few months with a family member who lived with the woman who was shot on the third floor. It’s unclear what the fight was over.

Riccio said there was no forced entry to the condo units. Police have recovered the handgun they believe was used in the shooting and are investigating how the man obtained it.

The alleged gunman had a history of recent financial problems, records show. His condo unit is in foreclosure, and he filed for bankruptcy two years ago, records show.

Police could be seen working at a second-floor condo unit at a building in the complex and had blocked off traffic in the area, but later reopened the street as they continued to investigate.