A Brooklyn transit police officer who shot and killed a knife-wielding man who slashed him was released from the hospital Friday after spending the night for observation.

Officer Filippo Gugliara, 24, left Lutheran Medical Center at 1:30 p.m. to applause from roughly 150 fellow officers.

Gugliara suffered a neck wound that required several stitches after, investigators said, he was attacked by the suspect, Oleg Tcherniak.

StoryOfficials: Cop kills suspect who slashed him photosRecent NYC mug shotsDataNYC crime rates

The officer was on routine patrol Thursday at the elevated Q-line station on Ocean Parkway when he heard a commotion from the street below. Gugliara rushed downstairs to Brighton Beach Avenue, a center for Eastern European immigrant communities, where he was told by witnesses that Tcherniak had assaulted a 78-year-old woman, knocking her to the ground, a law enforcement official said.

Gugliara was trying to arrest Tcherniak and was calling for assistance when Tcherniak pulled out a hunting knife and slashed the officer, according to investigators.

As Tcherniak tried to flee, Gugliara fired and struck him twice in the torso, killing him. Tcherniak died near Sea Breeze Avenue and West First Street and police said the knife was found a few inches away from his hand.

advertisement | advertise on newsday

Tcherniak, an emigrant from Ukraine who worked as a barber, had a sparse criminal record that included a sealed complaint of aggravated harassment, police said.

Tcherniak had had an argument with a customer who jostled him at a food store, the official said. Tcherniak left and returned, apparently in an attempt to confront the customer.

The 78-year-old woman saw Tcherniak return and was trying to calm him down when she was pushed to the ground, the official said.