A gunman holding hostages inside a South Florida apartment complex killed six people before being shot to death by a SWAT team that stormed the building early on Saturday following an hours-long standoff, police said.

Sergeant Eddie Rodriguez told The Associated Press that police got a call around 6.30pm on Friday that shots had been fired in a building with dozens of apartments in Hialeah, a few miles north of Miami. Although a crisis team was able to briefly establish communication with the man, Rodriguez said talks eventually "just fell apart" with the gunman, who was holding two hostages on the fifth floor. Both survived when officers stormed the building, fatally shooting the gunman during an exchange of gunfire.

"They made the decision to go in there and save and rescue the hostages," Rodriguez said.

The bodies of three women and two men were found at two apartment units inside the building, which Rodriguez said was in a "very quiet neighborhood."

Another man, who was walking his children into an apartment across the street, also was killed. Rodriguez said it wasn't immediately clear whether the gunman took aim at him from an upper-level balcony or if he was hit by a stray bullet.

"From up there, he was able to shoot at people across the street, catching this one man who was just walking into his apartment," Rodriguez said.

The entrance to the neighborhood, which is lined with apartment buildings, remained blocked off early on Saturday, including to those who live in the building where the standoff occurred. Miriam Valdes, 70, said she lives on the fifth floor of the building – one floor above where the shooting began. She said she heard gunfire and later saw smoke entering her apartment. She described running in fear to the unit across the hall, where she stayed holed up as officers negotiated with the gunman. From the apartment, Valdes said she could hear about eight officers talking with the gunman.

She said she heard the officers tell him to "let these people out." "We're going to help you," she said they told him. She said the gunman first asked for his girlfriend and then his mother but refused to cooperate.

Rodriguez said police were still investigating the motive and identifying the gunman and victims.

"Investigators are talking with families of the victims, neighbors, people that were present when all this began," he said. "That way we can start to piece together this huge puzzle that we're working with."