HIALEAH, Fla. – Four people, including a police officer, were hospitalized after a late night shooting in Hialeah.

The alleged gunman was shot and killed by police, who said they were forced to open fire.

Investigators worked into the early morning hours following what began as a tense hostage situation involving a child.

It all began around 9:30 p.m. Saturday when police said a 59-year-old man man went to his ex-girlfriend’s apartment, which is located along west 69th Street and 24th Avenue.

That man was armed and officers said he shot his ex-girlfriend and two of her relatives, a 31-year-old woman and a 51-year-old man. The 31-year-old woman, the daughter of the suspect’s ex-girlfriend, received two bullet wounds but has since been released from the hospital. The 51-year-old man is the ex-girlfriend’s new boyfriend, per police, and he remains hospitalized in critical condition after being shot twice.

According to police, the victims managed to get out of the home to seek help, and it was at that point the man locked himself inside of the apartment with his ex-girlfriend and their 9-year-old son.

A SWAT team attempted to enter the apartment, but that's when police said the man began shooting, striking one of the responding officers.

The officer was shot in the foot and taken to Ryder Trauma Center.

Following several hours of negotiations, SWAT officers managed to rescue the boy. His mother was hospitalized after being hit in the head and also wounded by a bullet, but she has since been released.

A confrontation ensued between the man and police, with officers saying they were forced to open fire, killing the suspect.

The child was not injured in the ordeal.

The injured officer was taken to Jackson Memorial Hospital but has since been released and is expected to make a full recovery.