A Brooklyn high school went on lockdown Tuesday afternoon after a man was shot nearby, according to the city police department.

"He was saying, 'I'm fine, I'm fine.' But I saw he was bleeding," a witness said. "And then when he went up the corner, he collapsed, and that's when I saw all the cops' cars come in."

Police said an 18-year-old man was shot near the intersection of Snyder and Flatbush Avenues around 2:42 p.m.

The victim walked passed Erasmus High School, officials said, before he collapsed at the intersection of Flatbush and Church Avenues.

Trails of blood could be seen on the sidewalk opposite the school. Police said the man is in stable condition.

It is not yet known if the victim was a student at Erasmus.

Police said they are looking into whether the shooting was gang-related.

City education department officials said no one in the school was injured, and the lockdown was eventually lifted.