The incident happened Tuesday around 8:30 p.m. on Ticonderoga Court in Ridge.
According to police, detectives went to an apartment to investigate a murder that happened back in June in Central Islip.
While interviewing a friend of the suspect who lived at the home, detectives learned the suspect, identified as Gary Jones, 38, of North Amityville, was inside. The friend, as well as some children, were directed out of the house.
Police said Jones then appeared from a room, armed with a gun, and fired several shots at the detectives, causing them to back out of the home.
One of the shots went through a wall, striking 3-year-old Lovely Toney in the next apartment, police said. She was rushed to a hospital, where she underwent surgery and is currently in stable condition.
"Shots came through my wall," said Lovely’s father, James.
Officials eventually entered with a robot and found Jones dead from a self-inflicted gunshot wound. Officers did not return fire.
The investigation is continuing.
As for Lovely, she’s expected to make a full recovery.
Suffolk County Police Commissioner Rodney Harrison lauded the responding officers for taking lifesaving measures to keep Lovely alive.
"Thank god for the men and women of the department," Harrison said. "Taking the life of this young girl into their arms and rushing her to the hospital."
Lovely’s father told FOX 5 NY that she was transferred to Cohen Children’s Medical Center. He says surgery is planned for Friday to close the wounds once the swelling goes down.