The incident happened at 6:20 p.m., as a group of kids were playing on the automated gate.
Mendy Gottlieb, 7, was apparently riding the gate up and down when he was lifted 15 to 20 feet in the air, and his head got trapped at the top.
Firefighters stood on the hood of an SUV to free him. He was transported to Bellevue Hospital, where he was treated for injuries that are not considered life threatening. He was discharged late Friday morning.
A large gap was visible on the top of the gate where the boy's head got stuck.
"They were playing on the gate, up and down," one witness said. "And one of the boys made a (signal) to go up, and it went up. This was the game, it was going up and down. Nobody stopped it."
Neighbors said they stood on each other's shoulders to help hold the boy up and alleviate the pressure on his head until rescue crews arrived. Eyewitnesses said the boy was stunned but conscious when rescued.
On Friday, the boy's mother Yachet Gottlieb said the incident scared her son. "Thank God he's home," she said.
Mendy would have been crushed, if it were not for a braking mechanism that stops the gate when it meets resistance.
He marked the Sabbath Friday night with his parents, and six brothers and sisters.
The child lives a few doors away from the building where he got stuck.
Almost exactly two years ago, there was another gate accident in Brooklyn, in Brownsville. Twelve-year-old Yakima McDonald was crushed to death when a parking gate he was hanging on rolled up.