As fire burned outside their apartments, blocking their escape through the front doors, about 20 people were trapped on the balconies of a three-story apartment complex in San Jose early Tuesday morning.

The residents were preparing to climb down using ropes and bed sheets, while neighbors on the ground brought mattresses in an effort to break their fall.

But before anyone needed to jump, San Jose firefighters arrived at the Summer Winds apartments off McLaughlin Avenue and Summerside Drive and rescued the trapped residents with ladders.

San Jose Fire Capt. Mitch Matlow said firefighters used “lots of ground ladders very quickly” to rescue the trapped residents.

“You can only take one person on a ladder at a time,” Matlow said. “So the firefighter and one other person on the ladder. You get them on the ground, then you bring the next person down.”

The fire affected the second third floors of one apartment building, displacing about 120 people, according to fire officials. It started in the kitchen of a second story unit.

Mayor Sam Liccardo stopped by the apartment complex late Tuesday morning to survey the damage and support residents, some of whom lost most of their possessions. As Liccardo walked the grounds, there was still a rope dangling from a third-floor balcony that residents were going to use to escape before firefighters arrived. There was also a mattress resting beneath a balcony.

“When you’ve got a rope coming off a balcony, that’s usually a recipe for a pretty tragic outcome,” Liccardo said. “We’re incredibly blessed. The firefighters acted so incredibly effectively to get everybody out of the apartment building without any injury at all.”

The blaze, which sparked on a second-story unit, was first reported at 5:33 a.m., according to the fire department. Four people were hospitalized due to smoke inhalation and 11 others were injured and treated at the scene.

The American Red Cross Silicon Valley responded to help the displaced residents find temporary housing. They received cots, blankets, supplies and a meal stipend, fire officials said.

“These are highly occupied apartments with multi–generational families in each apartment,” Matlow said.

Jose Fernandez and Kathy Ruiz were inside their apartment when they heard shouting and realized a fire was burning in an adjacent building in the complex.

“I looked out the window and saw a big black smoke,” Ruiz said. “You could see people on the third floor screaming for help because smoke was already coming out of the building.”

Fernandez said he quickly put on his shoes and ran outside. He threw a rope up to some people on a balcony, and caught a few personal belongings from one man.

“Everybody was in panic,” Fernandez said. “They were trying to make a decision, ‘should I jump?’ ”

Fernandez said another neighbor described his attempt to escape through the front door of his second-floor apartment, only to be met by a wall of flames.

“He smelled it, and the minute he stepped out to the hallway, there was already flames,” Fernandez said. “They had no choice but to go back in their apartment.”

By 7:30 a.m., firefighters from throughout the city had knocked down the blaze. Residents from 36 units were evacuated, and there was no immediate estimated time for when they would be allowed to return.

Sometime after 8 a.m., after a few hours of searching, Ruiz found the man who had thrown him his belongings and returned them.